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 <kfan(a)redhat.com>
---
kdumpctl | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 24f5cf7..2107e3e 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -152,8 +152,15 @@ rebuild_kdump_initrd()
rebuild_initrd()
{
if [[ ! -w "$KDUMP_BOOTDIR" ]];then
- derror "$KDUMP_BOOTDIR does not have write permission. Can not rebuild
$TARGET_INITRD"
- return 1
+ VAR_TARGET_INITRD_DIR="/var/lib/kdump"
+ mkdir -p "$VAR_TARGET_INITRD_DIR"
+ TARGET_INITRD_BASE="$(basename $TARGET_INITRD)"
+ TARGET_INITRD="$VAR_TARGET_INITRD_DIR/$TARGET_INITRD_BASE"
+ dwarn "$KDUMP_BOOTDIR does not have write permission. Rebuilding initrd at
$TARGET_INITRD"
+ if [[ ! -w "$VAR_TARGET_INITRD_DIR" ]];then
+ derror "$VAR_TARGET_INITRD_DIR does not have write permission. Cannot rebuild
$TARGET_INITRD"
+ return 1
+ fi
fi
if [ $DEFAULT_DUMP_MODE == "fadump" ]; then
@@ -656,6 +663,9 @@ load_kdump()
KEXEC_ARGS="$KEXEC_ARGS -s"
fi
+ # Relabel the target initrd for SELinux.
+ chcon -t boot_t $TARGET_INITRD
+
ddebug "$KEXEC $KEXEC_ARGS $standard_kexec_args --command-line=$KDUMP_COMMANDLINE
--initrd=$TARGET_INITRD $KDUMP_KERNEL"
# The '12' represents an intermediate temporary file descriptor
--
2.29.2
Show replies by date