How to install and configure kdump on CENTOS7 and RHEL7

How to install and configure kdump on CENTOS7 and RHEL7


In this article, I will show you How to install and configure kdump on CENTOS7 and RHEL7. Let’s cover the basic of Kernel crash dump mechanism, also known as kdump.

Activation of the kdump service is a part of the installation process, and by default, kdump is enabled during the installation and however, I will show you how to manually enable it. if it is still disabled after the installation.

What is kdump?

The kdump mechanism relies on the kexec system call, which can be used to boot a Linux kernel from the context of another kernel, bypass BIOS, and preserve the contents of the first kernel’s memory that would otherwise be lost.

Dumping mechanism of the crashed kernel using kdump:

When kernel crash occurs, kdump uses kexec to boot into a second kernel (a capture kernel), which resides in a reserved part of the system memory that is inaccessible to the first kernel. The second kernel captures the contents of the crashed kernel’s memory (a crash dump) and saves it.

If Kdump is not enabled and installed, we can check and install by using below command and change its status.

rpm -q | grep kexec-tools

If not installed, to install kdump, enter as the root user:

yum install kexec-tools -y

To configure kdump, use either the command line or graphical user interface. If you need to install the graphical configuration tool:

yum install system-config-kdump -y

Configuring kdump:

Now we are configuring the main file as we have to open the /etc/default/grub configuration file as root user. In this file, locate the line beginning with GRUB_CMDLINE_LINUX. The line will look similar to the following:

vim /etc/default/grub

GRUB_DISTRIBUTOR=”$(sed ‘s, release .*$,,g’ /etc/system-release)” GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT=”console” GRUB_CMDLINE_LINUX=”crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet”

Note the highlighted crashkernel= option; this is where the reserved memory is configured as auto. Change the value of the crashkernel= option to the amount of memory you want to reserve. For example, to reserve 128 MB of memory, use the following:


crashkernel memory value set logic is, consider on the x86_64 architecture, the amount of reserved memory will be 160,MB + 2,bits for every 4,KB of RAM. On a system with 1,TB of total physical memory installed, this means 224,MB (160,MB + 64,MB).

Finally, regenerate the GRUB2 configuration using the edited default file. If your system uses BIOS firmware, execute the following command:

# grub2-mkconfig -o /boot/grub2/grub.cfg

On a system with UEFI firmware, execute the following instead:

# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

After finishing the procedure above, the boot loader is reconfigured and the amount of memory you have specified in its configuration file will be reserved after the next reboot.

Configuring the kdump crush capture:

When a kernel crash is captured, the core dump can be either stored as a file in a local file system, written directly to a device, or sent over a network using the NFS (Network File System) or SSH (Secure Shell) protocol.

Only one of these options can be set at the moment, and the default option is to store the vmcore file in the /var/crash/ directory of the local file system. To change this, as root, open the /etc/kdump.conf configuration file and modify it as your required.

# vim /etc/kdump.conf

#raw /dev/vg/lv_kdump
#ext4 /dev/vg/lv_kdump
#ext4 LABEL=/boot
#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937
#nfs my.server.com:/export/tmp
#ssh [email protected]
#sshkey /root/.ssh/kdump_id_rsa path /var/crash
core_collector makedumpfile -l –message-level 1 -d 31
#core_collector scp
#kdump_post /var/crash/scripts/kdump-post.sh
#kdump_pre /var/crash/scripts/kdump-pre.sh #extra_bins /usr/bin/lftp #extra_modules gfs2
#default shell
#force_rebuild 1
#dracut_args –omit-drivers “cfg80211 snd” –add-drivers “ext2 ext3” #fence_kdump_args -p 7410 -f auto -c 0 -i 10
#fence_kdump_nodes node1 node2

Enabling and start the Service:

To start the kdump daemon at boot time, type the following at a shell prompt as root This will enable the service for multi-user. Target.

# systemctl enable kdump.service

Similarly, type following command to start, stop, restart the service (use the following command as root):

# systemctl start kdump.service
# systemctl stop kdump.service
# systemctl restart kdump.service