Kdump is the Linux kernel crash dumping mechanism. In the event of a system crash, Kdump provides a memory dump (vmcore) image. This image can assist in determining the cause of the crash. It is highly recommended that you enable the Kdump feature.
Kexec and Kdump together ensure faster bootup and the creation of reliable kernel vmcores for diagnostic purposes. Kexec is a fast-boot mechanism that allows booting a Linux kernel from the context of an already running kernel without going through BIOS. Kdump uses Kexec to boot into a second kernel whenever the system crashes. The crash dump is captured from the context of a freshly booted kernel and not from the context of the crashed kernel. This second kernel boots with very little memory and captures the dump image.
Installing and configuring kdump
To enable and use Kdump, install the following package:
# yum install kexec-tools
Enabling Kdump requires you to reserve a portion of the system memory for the capture kernel. This portion of memory is unavailable for other uses. The amount of memory that is reserved for the Kdump kernel is represented by the crashkernel boot parameter. This is appended to the kernel line in the GRUB configuration file, /boot/grub2/grub.cfg. The following example enables Kdump and reserves 128 MB of memory:
linux16 /vmlinuz-3.10.0-514.el7.x86_64 root=/dev/mapper/cl-root ro crashkernel=128M
In addition to reserving memory, you can designate the starting address (offset) of this reserved memory. For example, adding the following option to the kernel line reserves 128 MB of memory, starting at physical address 0x01000000 (16 MB):
crashkernel=128M@16M
– To set the offset to 48M:
crashkernel=128M@48M
– If you have more than 128 GB RAM, use the following setting:
crashkernel=512M@64M
– If more control is needed over the size and placement of the reserved memory, use the following format:
crashkernel=range1:size1[,range2:size2,...][@offset]
– The range[n] value specifies a range of values that are matched against the amount of physical RAM present in the system. The corresponding size[n] value specifies the amount of Kexec memory to reserve.
– The following example tells Kexec to reserve 64 MB of RAM if the system contains between 512 MB and 2 GB of memory. If the system contains more than 2 GB of physical memory, reserve 128 MB:
crashkernel=512M-2G:64M,2G-:128M
– On x86_64 systems with at least 2 GB of memory, you can allocate memory for kdump automatically. Use the following parameter to automatically allocate memory for kdump:
crashkernel=auto
Enabling kdump
After adding the crashkernel parameter to the /boot/grub2/grub.cfg file, reboot your system so that memory is reserved for the capture kernel. The “free –m
” command correctly shows that less memory is available for the system.
Use the systemctl command to enable the Kdump service to start at boot time. Use the systemctl command to start the Kdump service.
# systemctl enable kdump # systemctl start kdump
This loads your kernel-kdump image via Kexec, leaving your system ready to capture a vmcore on crashing.
Generate force crash dump
You can test the kdump configuration by force-crashing your system using the following command:
# echo c > /proc/sysrq-trigger
This causes panic output to be displayed, followed by the system restarting into the Kdump kernel. When the boot process gets to the point where it starts the Kdump service, the vmcore is copied to disk to the default location, /var/crash/[YYYY-MM-DD-HH:MM]/vmcore. The system then reboots back into the normal kernel.
Note:
Kdump is not supported on Xen domU guests. Virtualized systems can use the xm dump-core command for panics.