Skip to content

Commit 4612f09

Browse files
committed
Support saving crash dumps on systems hosted in RAM
By default, Kdump reboots the system after the crash dump is saved. While this works in most cases, it does not work for systems hosted in RAM where the crash dump is lost once rebooted. To support this scenario, a new option in the kdump.conf, save_core_to_ram, is added and set to 0 by default. Setting this option to 1 will disable the reboot and use the core_collector config option, if specified, to save a compressed dump. This is necessary because there is no disk to save the dump to, and there is not enough space in memory to copy the entirety of the crashed kernel's memory space using the `cp` command. Instead, a compressed ump must be saved to meet these space limitations.
1 parent 1bc0923 commit 4612f09

4 files changed

Lines changed: 47 additions & 4 deletions

File tree

SPECS/kexec-tools/kdump.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@
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+
# - Disables the default action to copy the entire vmcore and to reboot
167+
# after the crash dump is saved. Instead, a compressed crash dump is
168+
# saved and the system remains up afterwards. This is particularly useful
169+
# when the operating system is running in RAM and reboots would otherwise remove
170+
# the crash dump.
171+
# Specify 1 to disable rebooting once the crash dump is saved.
172+
#
165173

166174
#raw /dev/vg/lv_kdump
167175
#ext4 /dev/vg/lv_kdump
@@ -183,3 +191,4 @@ core_collector makedumpfile -l --message-level 1 -d 31
183191
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
184192
#fence_kdump_args -p 7410 -f auto -c 0 -i 10
185193
#fence_kdump_nodes node1 node2
194+
#save_core_to_ram 0

SPECS/kexec-tools/kdumpctl

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

90+
save_core_to_ram()
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+
CORE_COLLECTOR=`type -P $CORE_COLLECTOR`
98+
$CORE_COLLECTOR /proc/vmcore $coredir/vmcore
99+
else
100+
makedumpfile -l --message-level 1 -d 31 /proc/vmcore $coredir/vmcore
101+
fi
102+
}
103+
90104
rebuild_fadump_initrd()
91105
{
92106
local target_initrd_tmp
@@ -243,7 +257,7 @@ check_config()
243257
case "$config_opt" in
244258
\#* | "")
245259
;;
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)
260+
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)
247261
# remove inline comments after the end of a directive.
248262
[ -z "$config_val" ] && {
249263
echo "Invalid kdump config value for option $config_opt."
@@ -1248,6 +1262,23 @@ main ()
12481262
case "$1" in
12491263
start)
12501264
if [ -s /proc/vmcore ]; then
1265+
local _save_core_to_ram save_core_to_ram="0"
1266+
_save_core_to_ram=`grep ^save_core_to_ram $KDUMP_CONFIG_FILE 2>/dev/null`
1267+
1268+
if [ $? -eq 0 ]; then
1269+
save_core_to_ram=`echo $_save_core_to_ram | cut -d' ' -f2`
1270+
1271+
if [ "$save_core_to_ram" != "0" ] && [ "$save_core_to_ram" != "1" ]; then
1272+
echo "Error: save_core_to_ram value is invalid"
1273+
return 1
1274+
fi
1275+
fi
1276+
1277+
if [ "$save_core_to_ram" == "1" ]; then
1278+
save_core_to_ram
1279+
exit 0
1280+
fi
1281+
12511282
save_core
12521283
reboot
12531284
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": "ac3a8fa40431f3ff0c8d29f4168e9553acfe2efd6973fe64124e8b79dda1e211",
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": "a16d67962e2e09a2318715f3e20098a739296ac5132e6cd1357bd56185d28cc3",
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Summary: The kexec/kdump userspace component
77
Name: kexec-tools
88
Version: 2.0.27
9-
Release: 7%{?dist}
9+
Release: 8%{?dist}
1010
License: GPLv2
1111
Vendor: Microsoft Corporation
1212
Distribution: Azure Linux
@@ -330,6 +330,9 @@ done
330330
/usr/share/makedumpfile/
331331

332332
%changelog
333+
* Mon Sep 30 2024 Nicholas Angelastro <nangelastro@microsoft.com> - 2.0.27-8
334+
- Support saving crash dumps on systems hosted in RAM
335+
333336
* Tue Jul 09 2024 Chris Co <chrco@microsoft.com> - 2.0.27-7
334337
- Remove requires on dhcp-client
335338

0 commit comments

Comments
 (0)