Skip to content

Commit cb14ab9

Browse files
committed
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.
1 parent 89fa17e commit cb14ab9

4 files changed

Lines changed: 53 additions & 3 deletions

File tree

SPECS/kexec-tools/kdump.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@
162162
# to send fence_kdump notifications to.
163163
# (this option is mandatory to enable fence_kdump).
164164
#
165+
# save_core_to_ram <0 | 1>
166+
# - By default, the entire vmcore gets copied and the system reboots
167+
# after the crash dump is saved. Enabling this option by specifying
168+
# 1 will instead save a compressed dump and not reboot after the
169+
# dump is saved. The core_collector option, if also specified, is
170+
# used to determine how the crash dump should be compressed. If the
171+
# core_collector option is not set, then only the dmesg log will
172+
# be saved.
173+
#
174+
# This option is particularly useful when the operating system is
175+
# running in RAM and reboots would otherwise remove the crash dump.
176+
#
165177

166178
#raw /dev/vg/lv_kdump
167179
#ext4 /dev/vg/lv_kdump
@@ -183,3 +195,4 @@ core_collector makedumpfile -l --message-level 1 -d 31
183195
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
184196
#fence_kdump_args -p 7410 -f auto -c 0 -i 10
185197
#fence_kdump_nodes node1 node2
198+
#save_core_to_ram 0

SPECS/kexec-tools/kdumpctl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ save_core()
8787
fi
8888
}
8989

90+
save_compressed_core()
91+
{
92+
coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`"
93+
mkdir -p $coredir
94+
CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2`
95+
96+
if [[ -n $CORE_COLLECTOR ]]; then
97+
# Utilize the core_collector option set in kdump.conf to produce a compressed crash dump.
98+
CORE_COLLECTOR=`type -P $CORE_COLLECTOR`
99+
$CORE_COLLECTOR /proc/vmcore $coredir/vmcore
100+
else
101+
# Resort to extracting the dmesg log from vmcore instead of compressing and filtering the vmcore.
102+
# This should produce the minimum-sized output that can reliably fit in memory.
103+
makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg >/dev/null 2>&1
104+
fi
105+
}
106+
90107
rebuild_fadump_initrd()
91108
{
92109
local target_initrd_tmp
@@ -243,7 +260,7 @@ check_config()
243260
case "$config_opt" in
244261
\#* | "")
245262
;;
246-
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)
263+
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)
247264
# remove inline comments after the end of a directive.
248265
[ -z "$config_val" ] && {
249266
echo "Invalid kdump config value for option $config_opt."
@@ -1248,6 +1265,23 @@ main ()
12481265
case "$1" in
12491266
start)
12501267
if [ -s /proc/vmcore ]; then
1268+
local _save_core_to_ram save_core_to_ram="0"
1269+
_save_core_to_ram=`grep ^save_core_to_ram $KDUMP_CONFIG_FILE 2>/dev/null`
1270+
1271+
if [ $? -eq 0 ]; then
1272+
save_core_to_ram=`echo $_save_core_to_ram | cut -d' ' -f2`
1273+
1274+
if [ "$save_core_to_ram" != "0" ] && [ "$save_core_to_ram" != "1" ]; then
1275+
echo "Error: save_core_to_ram value is invalid"
1276+
return 1
1277+
fi
1278+
fi
1279+
1280+
if [ "$save_core_to_ram" == "1" ]; then
1281+
save_compressed_core
1282+
exit 0
1283+
fi
1284+
12511285
save_core
12521286
reboot
12531287
else

SPECS/kexec-tools/kexec-tools.signatures.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"kdump-lib-initramfs.sh": "ff4b63f99470ee796fd7e4a532dde241c4da02909306926a08a172457775a92a",
2121
"kdump-lib.sh": "3d50507626d4a92b8448c7d6604923f6f460c4cb5c8b18977381a7d5e516dfba",
2222
"kdump-udev-throttler": "125d538a59172f779b40ea32fea1e4eb50d849f25eb2537a48328d4401136679",
23-
"kdump.conf": "c4cd6c4a2f00e7df10d939bc2f35f8b6b8a3edd71245aa3ba0d7fff53d9f42e8",
23+
"kdump.conf": "2e65b6237560286f74530e104ee6556387b5c08ced883b1bb0a443d1e6d3c0cb",
2424
"kdump.conf.5": "bab6c7b171f76e8c6df91bb7db852815caacbc3cd3d4309a1dc58d36950440e4",
2525
"kdump.service": "ed8d22fafa6cfafaddcfd9fec82e3fa7fa42aa0366f69676fafa97e200b0506a",
2626
"kdump.sysconfig": "d03a24659c08aa4ce5a8e54edbe64e149f8c572c76c4e338d84dbdfbeab8fb63",
2727
"kdump.sysconfig.aarch64": "a829f3a0f88d983ccec2782b048f12a2eafca71aac4dd42acac2eaea8f7dd8d9",
2828
"kdump.sysconfig.i386": "1175bcc11be49841d4b8c3f9612e68bb7b2e0e8f00067ffa782fd9dba04f821d",
2929
"kdump.sysconfig.x86_64": "850b3be780165d0721edb8d34b2ba28aafc60b29850ff627daf04190369e359c",
30-
"kdumpctl": "34976fa2ca34a455f393d2ac212a628d73ba4113b44f0e819c3cb5b1195e504b",
30+
"kdumpctl": "f681dbcdabbcc791e9839c3a349532081f1ccfb51b76ad6b2268f717a913fb47",
3131
"kdumpctl.8": "025a39d212eed0584da7c23c1bb50d6ab797a0fa3c686ac6b80391af875dbaec",
3232
"kexec-kdump-howto.txt": "e783390a9aa582a2b5e7981cd3277081385340b5873a3f0633c789811876eccb",
3333
"kexec-tools-2.0.27.tar.xz": "38d78bcfa33a88928324b57dc81f50c1dfc279eede45e80957ca18f4e84b8187",

SPECS/kexec-tools/kexec-tools.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ done
330330
/usr/share/makedumpfile/
331331

332332
%changelog
333+
* Mon Mar 31 2026 Nicholas Angelastro <nangelastro@microsoft.com> - 2.0.27-9
334+
- Support saving crash dumps on systems hosted in RAM
335+
333336
* Tue Nov 11 2025 Mayank Singh <mayansingh@microsoft.com> - 2.0.27-8
334337
- Updated dependency handling for kexec-tools:
335338
Changed from hard dependency on a single package.

0 commit comments

Comments
 (0)