From cb14ab9e0493d2bf672a30cff64fc5235e8c0ae4 Mon Sep 17 00:00:00 2001 From: Nicholas Angelastro Date: Mon, 30 Sep 2024 11:31:34 -0700 Subject: [PATCH] Support saving crash dumps on systems hosted in RAM By default, Kdump copies the entire vmcore to the disk and reboots the system afterwards. While this works in most cases, it does not work for systems hosted in RAM where the crash dump will be lost once rebooted. To support this scenario, a new option in the kdump.conf, save_core_to_ram, is added and commented out. Setting this option to 1 will allow a compressed crash dump to be produced by utilizing the core_collector option if specified, otherwise the dmesg log will be extracted from the vmcore. This is especially necessary because there is no disk to save the dump to, and there is not enough space in the pre-allocated crashkernel memory space to save an entire vmcore. --- SPECS/kexec-tools/kdump.conf | 13 +++++++ SPECS/kexec-tools/kdumpctl | 36 ++++++++++++++++++- SPECS/kexec-tools/kexec-tools.signatures.json | 4 +-- SPECS/kexec-tools/kexec-tools.spec | 3 ++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/SPECS/kexec-tools/kdump.conf b/SPECS/kexec-tools/kdump.conf index ed78507b273..58620153785 100644 --- a/SPECS/kexec-tools/kdump.conf +++ b/SPECS/kexec-tools/kdump.conf @@ -162,6 +162,18 @@ # to send fence_kdump notifications to. # (this option is mandatory to enable fence_kdump). # +# save_core_to_ram <0 | 1> +# - By default, the entire vmcore gets copied and the system reboots +# after the crash dump is saved. Enabling this option by specifying +# 1 will instead save a compressed dump and not reboot after the +# dump is saved. The core_collector option, if also specified, is +# used to determine how the crash dump should be compressed. If the +# core_collector option is not set, then only the dmesg log will +# be saved. +# +# This option is particularly useful when the operating system is +# running in RAM and reboots would otherwise remove the crash dump. +# #raw /dev/vg/lv_kdump #ext4 /dev/vg/lv_kdump @@ -183,3 +195,4 @@ core_collector makedumpfile -l --message-level 1 -d 31 #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 +#save_core_to_ram 0 diff --git a/SPECS/kexec-tools/kdumpctl b/SPECS/kexec-tools/kdumpctl index 908de2d9a8a..015643c02eb 100755 --- a/SPECS/kexec-tools/kdumpctl +++ b/SPECS/kexec-tools/kdumpctl @@ -87,6 +87,23 @@ save_core() fi } +save_compressed_core() +{ + coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" + mkdir -p $coredir + CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2` + + if [[ -n $CORE_COLLECTOR ]]; then + # Utilize the core_collector option set in kdump.conf to produce a compressed crash dump. + CORE_COLLECTOR=`type -P $CORE_COLLECTOR` + $CORE_COLLECTOR /proc/vmcore $coredir/vmcore + else + # Resort to extracting the dmesg log from vmcore instead of compressing and filtering the vmcore. + # This should produce the minimum-sized output that can reliably fit in memory. + makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg >/dev/null 2>&1 + fi +} + rebuild_fadump_initrd() { local target_initrd_tmp @@ -243,7 +260,7 @@ check_config() case "$config_opt" in \#* | "") ;; - raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) + raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes|save_core_to_ram) # remove inline comments after the end of a directive. [ -z "$config_val" ] && { echo "Invalid kdump config value for option $config_opt." @@ -1248,6 +1265,23 @@ main () case "$1" in start) if [ -s /proc/vmcore ]; then + local _save_core_to_ram save_core_to_ram="0" + _save_core_to_ram=`grep ^save_core_to_ram $KDUMP_CONFIG_FILE 2>/dev/null` + + if [ $? -eq 0 ]; then + save_core_to_ram=`echo $_save_core_to_ram | cut -d' ' -f2` + + if [ "$save_core_to_ram" != "0" ] && [ "$save_core_to_ram" != "1" ]; then + echo "Error: save_core_to_ram value is invalid" + return 1 + fi + fi + + if [ "$save_core_to_ram" == "1" ]; then + save_compressed_core + exit 0 + fi + save_core reboot else diff --git a/SPECS/kexec-tools/kexec-tools.signatures.json b/SPECS/kexec-tools/kexec-tools.signatures.json index cfc83937bd7..52d6e0d77c6 100644 --- a/SPECS/kexec-tools/kexec-tools.signatures.json +++ b/SPECS/kexec-tools/kexec-tools.signatures.json @@ -20,14 +20,14 @@ "kdump-lib-initramfs.sh": "ff4b63f99470ee796fd7e4a532dde241c4da02909306926a08a172457775a92a", "kdump-lib.sh": "3d50507626d4a92b8448c7d6604923f6f460c4cb5c8b18977381a7d5e516dfba", "kdump-udev-throttler": "125d538a59172f779b40ea32fea1e4eb50d849f25eb2537a48328d4401136679", - "kdump.conf": "c4cd6c4a2f00e7df10d939bc2f35f8b6b8a3edd71245aa3ba0d7fff53d9f42e8", + "kdump.conf": "2e65b6237560286f74530e104ee6556387b5c08ced883b1bb0a443d1e6d3c0cb", "kdump.conf.5": "bab6c7b171f76e8c6df91bb7db852815caacbc3cd3d4309a1dc58d36950440e4", "kdump.service": "ed8d22fafa6cfafaddcfd9fec82e3fa7fa42aa0366f69676fafa97e200b0506a", "kdump.sysconfig": "d03a24659c08aa4ce5a8e54edbe64e149f8c572c76c4e338d84dbdfbeab8fb63", "kdump.sysconfig.aarch64": "a829f3a0f88d983ccec2782b048f12a2eafca71aac4dd42acac2eaea8f7dd8d9", "kdump.sysconfig.i386": "1175bcc11be49841d4b8c3f9612e68bb7b2e0e8f00067ffa782fd9dba04f821d", "kdump.sysconfig.x86_64": "850b3be780165d0721edb8d34b2ba28aafc60b29850ff627daf04190369e359c", - "kdumpctl": "34976fa2ca34a455f393d2ac212a628d73ba4113b44f0e819c3cb5b1195e504b", + "kdumpctl": "f681dbcdabbcc791e9839c3a349532081f1ccfb51b76ad6b2268f717a913fb47", "kdumpctl.8": "025a39d212eed0584da7c23c1bb50d6ab797a0fa3c686ac6b80391af875dbaec", "kexec-kdump-howto.txt": "e783390a9aa582a2b5e7981cd3277081385340b5873a3f0633c789811876eccb", "kexec-tools-2.0.27.tar.xz": "38d78bcfa33a88928324b57dc81f50c1dfc279eede45e80957ca18f4e84b8187", diff --git a/SPECS/kexec-tools/kexec-tools.spec b/SPECS/kexec-tools/kexec-tools.spec index 0594f600895..e3910e8c7f0 100644 --- a/SPECS/kexec-tools/kexec-tools.spec +++ b/SPECS/kexec-tools/kexec-tools.spec @@ -330,6 +330,9 @@ done /usr/share/makedumpfile/ %changelog +* Mon Mar 31 2026 Nicholas Angelastro - 2.0.27-9 +- Support saving crash dumps on systems hosted in RAM + * Tue Nov 11 2025 Mayank Singh - 2.0.27-8 - Updated dependency handling for kexec-tools: Changed from hard dependency on a single package.