How to Configure kdump for CentOS/RHEL 9

The Kdump feature in RHEL provides a crash dumping mechanism that captures diagnostic information when the kernel crashes. Kdump works by using the kexec system call to boot into a capture kernel without rebooting the system. This capture kernel reserves part of system memory and saves the contents of the crashed kernel’s memory as a vmcore dump file. Analyzing this vmcore file helps determine the cause of the kernel malfunction.

Enabling Kdump is highly recommended for mission-critical environments since the vmcore file may be the only information available after a system failure. However, Kdump requires permanently reserving part of system memory for the capture kernel, reducing memory available to the main kernel. Carefully ensure the system meets Kdump’s memory requirements before enabling this critical feature. See Working With Kernel Dumps for more information.

This post explains configuring kdump on a CentOS/RHEL 9 system.

Installing kdump

1. Use dnf to install the kdump package (kexec-tools) as root:

# dnf install kexec-tools

2. To reserve memory for the kdump kernel, edit the /etc/default/grub file and set the crashkernel= option to the desired amount. For example, to reserve 64 MB, set crashkernel=64M.

# cat /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=64M"

3. You can also configure the amount of reserved memory as a variable by using this syntax: crashkernel=range1:size1,range2:size2. For instance, you could set the memory as a variable like this:

# cat /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=512M-2G:64M,2G-:128M"

4. Consider defining an offset value for the reserved memory (Optional). To reserve memory with a crashkernel, some systems require specifying a fixed offset, as this reservation happens very early in the boot process. With a fixed offset, the reserved memory starts at the designated point. For instance, to reserve 128 MB beginning at 16 MB, you would specify:

# cat /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=128M@16M"

If no offset value is set, Kdump offsets reserved memory automatically.

5. Refresh the grub configuration to apply changes:

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

6. For systems configured to use UEFI-based, run the following command to rebuild the grub.cfg:

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

7. Enable the kdump service:

# $ sudo systemctl enable --now kdump.service

8. Reboot the system and finish configuring Kdump.

Default kdump Failure State

By default, if kdump does not successfully send the crash dump data to the configured output locations, it reboots the server, deleting any collected dump data. To prevent losing the dump data, you can uncomment and edit the default setting in /etc/kdump.conf to disable the automatic reboot.

default dump_to_rootfs
Related Post