From ac55095191b7ea8fa9f4e7018c3336a8f4eca892 Mon Sep 17 00:00:00 2001 From: Kenneth Dsouza Date: Thu, 11 Oct 2018 13:54:58 +0530 Subject: [PATCH] kdump-lib-initramfs.sh: Add check to remount to rw mode only if dump target is ro. Currently the script does not check if the dump target is read-only and would always mount to read-write mode. This caused an issue with nfs mount as the fstab options would be reconsidered while remounting to read-write mode. The remount would fail with the below error as all options cannot be changed runtime. mount.nfs: mount(2): Invalid argument mount.nfs: an incorrect mount option was specified Which in result would not save the vmcore on the dump target. This patch addresses this issue by checking the dump target status for read-only. If yes, remount to read-write mode without reconsidering the fstab options. Signed-off-by: Kenneth D'souza Acked-by: Kairui Song --- kdump-lib-initramfs.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 2c18c87..c7f874f 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -87,6 +87,7 @@ dump_fs() local _dev=$(findmnt -k -f -n -r -o SOURCE $1) local _mp=$(findmnt -k -f -n -r -o TARGET $1) + local _op=$(findmnt -k -f -n -r -o OPTIONS $1) echo "kdump: dump target is $_dev" @@ -100,7 +101,12 @@ dump_fs() echo "kdump: saving to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" - mount -o remount,rw $_mp || return 1 + # Only remount to read-write mode if the dump target is mounted read-only. + if [[ "$_op" = "ro"* ]]; then + echo "kdump: Mounting Dump target $_dev in rw mode." + mount -o remount,rw $_dev $_mp || return 1 + fi + mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1 save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"