fadump: fix default initrd backup and restore logic

Resolves: bz2139000
Upstream: Fedora
Conflict: None

commit 25411da9660e732a53e675936813aad924ba65df
Author: Hari Bathini <hbathini@linux.ibm.com>
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 <hbathini@linux.ibm.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Lichen Liu <lichliu@redhat.com>
This commit is contained in:
Lichen Liu 2022-12-22 13:39:34 +08:00
parent fb93b28df8
commit 73721c9a94
1 changed files with 4 additions and 2 deletions

View File

@ -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"