From 73721c9a949ec136e3c0d784d97bb0a09c51f842 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Thu, 22 Dec 2022 13:39:34 +0800 Subject: [PATCH] fadump: fix default initrd backup and restore logic Resolves: bz2139000 Upstream: Fedora Conflict: None commit 25411da9660e732a53e675936813aad924ba65df Author: Hari Bathini Date: Fri Dec 2 18:46:50 2022 +0530 fadump: fix default initrd backup and restore logic In case of fadump, default initrd is rebuilt with dump capturing capability, as the same initrd is used for booting production kernel as well as capture kernel. The original initrd file is backed up with a checksum, to restore it as the default initrd when fadump is disabled. As the checksum file is not kernel version specific, switching between different kernel versions and kdump/fadump dump mode breaks the default initrd backup/restore logic. Fix this by having a kernel version specific checksum file. Also, if backing up initrd fails, retaining the checksum file isn't useful. Remove it. Signed-off-by: Hari Bathini Reviewed-by: Philipp Rudo Signed-off-by: Lichen Liu --- kdumpctl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 94c7e2b..ebba5f8 100755 --- a/kdumpctl +++ b/kdumpctl @@ -11,10 +11,10 @@ MKFADUMPRD="/sbin/mkfadumprd" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" -INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" DUMP_TARGET="" DEFAULT_INITRD="" DEFAULT_INITRD_BAK="" +INITRD_CHECKSUM_LOCATION="" KDUMP_INITRD="" TARGET_INITRD="" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" @@ -188,7 +188,8 @@ backup_default_initrd() sha1sum "$DEFAULT_INITRD" > "$INITRD_CHECKSUM_LOCATION" if ! cp "$DEFAULT_INITRD" "$DEFAULT_INITRD_BAK"; then dwarn "WARNING: failed to backup $DEFAULT_INITRD." - rm -f "$DEFAULT_INITRD_BAK" + rm -f -- "$INITRD_CHECKSUM_LOCATION" + rm -f -- "$DEFAULT_INITRD_BAK" fi fi } @@ -314,6 +315,7 @@ setup_initrd() fi DEFAULT_INITRD_BAK="$KDUMP_BOOTDIR/.$(basename "$DEFAULT_INITRD").default" + INITRD_CHECKSUM_LOCATION="$DEFAULT_INITRD_BAK.checksum" if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then TARGET_INITRD="$DEFAULT_INITRD"