How to Configure kdump on RHEL 7

About kdump and kexec

kdump is a service which provides a crash dumping mechanism. The service enables you to save the contents of the system memory for analysis.

kdump uses the kexec system call to boot into the second kernel (a capture kernel) without rebooting; and then captures the contents of the crashed kernel’s memory (a crash dump or a vmcore) and saves it into a file. The second kernel resides in a reserved part of the system memory.

Memory requirements

For example, on the x86_64 architecture, the amount of reserved memory is 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).

On many systems, kdump can estimate the amount of required memory and reserve it automatically. On the x86_64 architecture, 2GB is minimum amount of memory required for automatic memory reservation.

Installing and configuring kdump

  1. Installing kdump.

    rpm -q kexec-tools

    yum install kexec-tools
  2. Regenerate the GRUB2 configuration.

    Open the /etc/default/grub configuration file as root using a plain text editor such as vim or Gedit.

    In this file, locate the line beginning with GRUB_CMDLINE_LINUX, add the the crashkernel=auto option of the required kernel command-line parameter. Then, save the file and exit the editor, similar to the following:

    GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/swap rd.lvm.lv=rhel/root rhgb quiet"

    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
  3. Modify the kdump configuration file /etc/kdump.conf.

    ~]# grep -v ^# /etc/kdump.conf | grep -v ^$
    path /var/crash
    core_collector makedumpfile -c --message-level 1 -d 31
  4. Enabling the service.

    To start the kdump daemon at boot time, type the following at a shell prompt as root:

    systemctl enable kdump.service

    To start the service in the current session, use the following command as root:

    systemctl start kdump.service
  5. Testing the kdump configuration.

    To test the configuration, reboot the system with kdump enabled, and make sure that the service is running:

    ~]# systemctl is-active kdump
    active

    Then type the following commands at a shell prompt:

    echo 1 > /proc/sys/kernel/sysrq
    echo c > /proc/sysrq-trigger

    This forces the Linux kernel to crash, and the address-YYYY-MM-DD-HH:MM:SS/vmcore file is copied to the location you have selected in the configuration (that is, to /var/crash/ by default).