kexec-tools/60-kdump.install
Tao Liu 5f4c5f9819 Write to /var/lib/kdump if $KDUMP_BOOTDIR not writable
Resolves: bz1965952
Upstream: Fedora
Conflict: None

commit 75bdcb7399
Author: Kelvin Fan <kfan@redhat.com>
Date:   Fri Apr 16 22:31:13 2021 +0000

    Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not writable

    The `/boot` directory on some operating systems might be read-only.
    If we cannot write to `$KDUMP_BOOTDIR` when generating the kdump
    initrd, attempt to place the generated initrd at `/var/lib/kdump`
    instead.

    Signed-off by: Kelvin Fan <kelvinfan001@gmail.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-06-23 09:34:40 +08:00

37 lines
791 B
Bash
Executable File

#!/usr/bin/bash
COMMAND="$1"
KERNEL_VERSION="$2"
KDUMP_INITRD_DIR_ABS="$3"
KERNEL_IMAGE="$4"
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
exit 0
fi
if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then
KDUMP_INITRD="initrdkdump"
else
# If `KDUMP_BOOTDIR` is not writable, then the kdump
# initrd must have been placed at `/var/lib/kdump`
if [[ ! -w "/boot" ]]; then
KDUMP_INITRD_DIR_ABS="/var/lib/kdump"
else
KDUMP_INITRD_DIR_ABS="/boot"
fi
KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img"
fi
ret=0
case "$COMMAND" in
add)
# Do nothing, kdump initramfs is strictly host only
# and managed by kdump service
;;
remove)
rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
ret=$?
;;
esac
exit $ret