Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

Install and configure Kernel Crash Dump on Centos 8

In this article we will learn how to Install and configure Kernel Crash Dump on Centos 8.

Kdump is a service providing a crash dumping mechanism. The service enables you to save the contents of the system’s memory for later 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. The second kernel resides in a reserved part of the system memory.

Kernel Crash Dump on Centos 8

First, check if kdump is installed on your system using the following command:

rpm -q kexec-tools

Above output shows that kdump is already installed but in the legacy versions kump is not installed by default. Use the following command to install kdump:

- Advertisement -
yum install kexec-tools

In my case kdump is installed by default in CentOS / RHEL 8.

The memory for kdump is reserved during the system boot and memory size is configured in the system’s Grand Unified Bootloader (GRUB) 2 configuration file. The memory size depends on the crashkernel= value specified in the configuration file and the size of the system’s physical memory.

Estimating the kdump size:

When planning and building your kdump environment, you must know how much space the dump file requires. Following command estimates how much space the dump file requires. It generates a memory usage report, which helps you determine the dump level and which pages can be excluded.

makedumpfile --mem-usage /proc/kcore

Configuring kdump memory usage:

- Advertisement -

The crashkernel option is used to define reserved memory. You can specify the value or configure the auto option. The crashkernel=auto boot option, reserves memory automatically, depending on total amount of the system’s physical memory. When configured as auto, the kernel will automatically reserve an appropriate amount of required. This helps to prevent Out-of-Memory (OOM) error occurrences.

Run the following command to edit crashkernel value:

nano /etc/default/grub

Save and quit the file.

Use the following command to update GRUB file.

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

Configuring the kdump target:

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 a time, and the default behavior is to store the vmcore file in  /var/crash directory of the local file system.

To store the vmcore file in /var/crash directory of the local file system, run the following command:

nano /etc/kdump.conf

Configuring the core collector:

To reduce the size of the vmcore dump file, kdump allows you to specify an external application (a core collector) to compress the data. Edit the /etc/kdump.conf file and add the “core_collector makedumpfile -l –message-level 1 -d 31” property as shown below:

nano /etc/kdump.conf

Configuring the kdump default failure responses:

By default, when kdump fails to create a vmcore file at the configured target location, the system reboots and the dump is lost in the process. To change this behavior, Remove the # sign from the beginning of the failure_action line and replace it with “failure_action poweroff” in the /etc/kdump.conf configuration file.

nano /etc/kdump.conf

Enabling and disabling the kdump service:

Now kdump is installed and configured enable and start the kdump service using the following command:

systemctl enable kdump.service
systemctl start kdump.service
systemctl status kdump.service

Testing kdump Service:

Run the following comamnd to check if kdump is running:

systemctl is-active kdump

NOTE: Following steps are just for testing purpose donot try it on production / Live Systems:

Now force linux kernel to crash using the following commands:

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

Your kernel will be crashed and your machine will be rebooted to another kernel. Kdump is now installed and configured.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook