Configuring kdump Memory Reservations in Red Hat Enterprise Linux 7

Alright, kdump memory reservations in Red Hat Enterprise Linux 7. You know what I’m talking about right? That magical feature that saves your bacon when your system crashes and you need a dump of all the juicy details to figure out why it happened. But before we get into how to configure this bad boy, let me first explain why you should care in the first place.

Imagine this scenario: You’re working on some critical project that requires 100% uptime and suddenly your system crashes. Panic sets in as you realize you don’t have a recent backup or any logs to help you figure out what went wrong. But wait, there’s hope! If you’ve configured kdump memory reservations properly, you can save yourself hours of headache by automatically generating a crash dump that includes all the juicy details about your system’s state at the time of failure.

Now let’s get into how to configure this feature in Red Hat Enterprise Linux 7. To begin with, open up your terminal and navigate to /etc/default/. Here you will find a file called grub.conf that contains all sorts of boot-related goodness. Open it up with your favorite text editor (I prefer nano) and add the following line:

bash
# Set the variable GRUB_CMDLINE_LINUX to a string of boot options
GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root rhgb quiet fadump=on"

bash
# Add the option "rd.lvm.lv=rhel/swap" to the boot command, specifying the logical volume for swap
# Add the option "crashkernel=auto" to the boot command, setting the crashkernel size to be automatically determined
# Add the option "rd.lvm.lv=rhel/root" to the boot command, specifying the logical volume for the root file system
# Add the option "rhgb" to the boot command, enabling graphical boot
# Add the option "quiet" to the boot command, suppressing unnecessary boot messages
# Add the option "fadump=on" to the boot command, enabling firmware-assisted dump for kernel crash analysis

This line tells GRUB to automatically reserve memory for kdump and also enables some other useful features like LVM support, a quiet boot, and the ability to dump kernel messages (fadump). If you want to specify reserved boot memory instead of accepting defaults, configure crashkernel=xxM where xx is the amount of memory required in megabytes.

Once you’ve made your changes, save and close grub.conf. Next, update GRUB by running:

# This script uses the grubby command to update the kernel arguments for all kernels.
# The purpose of this command is to specify the amount of reserved boot memory for the kernel.
# The default value is used if no custom value is specified.
# The custom value is specified using the "crashkernel" argument, followed by the desired amount of memory in megabytes.
# The "--update-kernel" option is used to update the kernel arguments for all kernels.
# The "ALL" keyword specifies that the arguments should be updated for all kernels.
# The "--args" option is used to specify the arguments to be added or updated.
# The "grubby" command is used to manage GRUB boot loader configuration.
# The "--update-kernel" option is used to update the kernel arguments for a specific kernel.
# The "ALL" keyword specifies that the arguments should be updated for all kernels.
# The "--args" option is used to specify the arguments to be added or updated.
# The "crashkernel" argument is used to specify the amount of reserved boot memory for the kernel.
# The "<custom-value>" placeholder should be replaced with the desired amount of memory in megabytes.
grubby --update-kernel ALL --args "crashkernel=<custom-value>"

Replace with the custom crashkernel value that you have configured for kdump. Finally, reboot your system to apply changes.

Now how much memory to reserve for kdump. According to Red Hat documentation, on some systems it is possible to allocate memory automatically by using the crashkernel=auto parameter in GRUB or enabling this option in the graphical configuration utility. However, a certain amount of total memory needs to be available in the system for automatic reservation to work. The table below lists the thresholds for automatic memory allocation based on the system’s architecture:

#!/bin/bash

# This script displays a table of minimum thresholds for automatic memory reservation based on the system's architecture.

# The table is formatted with columns for Architecture and Threshold (in MB).

echo "Table 7.2: Minimum threshold for automatic memory reservation"

# The following line creates a horizontal line to separate the table header from the data.
echo "---------------------|------------------"

# The following lines use the echo command to print the data in the table, with each line representing a different architecture and its corresponding threshold.
echo "x86_32            | 1024"
echo "x86_64            | 5120"
echo "PowerPC          | 1024"
echo "s390             | 1024"

# The script ends here.

If your system has less memory than specified in the table, you’ll need to reserve memory manually. To do this, follow these steps:

1. Determine how much memory is required for kdump by running makedumpfile –mem-usage /proc/kcore. This will generate a memory usage report that helps determine the dump level and which pages are safe to exclude.
2. Add the following line to grub.conf, replacing with the amount of memory required in megabytes:

# Set the GRUB_CMDLINE_LINUX variable to configure the GRUB bootloader.
GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/swap"

# Generate a memory usage report using makedumpfile and set the value for "crashkernel" in the GRUB_CMDLINE_LINUX variable.
# This report helps determine the dump level and which pages are safe to exclude.
makedumpfile --mem-usage /proc/kcore

# Add the required memory value in megabytes to the GRUB_CMDLINE_LINUX variable.
# This value is used to set the "crashkernel" parameter in the GRUB bootloader configuration.
# Replace <custom-value> with the actual amount of memory required for kdump.
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX crashkernel=<custom-value>,<remaining-memory>"

3. Save and close grub.conf, update GRUB by running grubby –update-kernel ALL –args “crashkernel=“, reboot your system to apply changes.

And that’s it! You now have kdump memory reservations configured in Red Hat Enterprise Linux 7. Remember, this feature can save you hours of headache when dealing with critical issues. So give it a try!

SICORPS