fadump: fix dump capture failure to root disk

If the dump target is the root disk, kdump scripts add an entry in
/etc/fstab for root disk with /sysroot as the mount point. The root
disk, passed through root=<> kernel commandline parameter, is mounted
at /sysroot in read-only mode before switching from initial ramdisk.
So, in fadump mode, a remount of /sysroot to read-write mode is needed
to capture dump successfully, because /sysroot is already mounted as
read-only based on root=<> boot parameter.

Commit e8ef4db8ff ("Fix dump_fs mount point detection and fallback
mount") removed initialization of $_op variable, the variable holding
the options the dump target was mounted with, leading to the below
error as remount was skipped:

  kdump[586]: saving to /sysroot/var/crash/127.0.0.1-2021-04-22-07:22:08/
  kdump.sh[587]: mkdir: cannot create directory '/sysroot/var/crash/127.0.0.1-2021-04-22-07:22:08/': Read-only file system
  kdump[589]: saving vmcore failed

Restore $_op variable initialization in dump_fs() function to fix this.

Fixes: e8ef4db8ff ("Fix dump_fs mount point detection and fallback mount")
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Hari Bathini 2021-04-22 18:21:59 +05:30 committed by Kairui Song
parent 8d0ef743e0
commit d0e9c51e0d

View File

@ -119,7 +119,8 @@ dump_fs()
{
local _exitcode
local _mp=$1
ddebug "dump_fs _mp=$_mp"
local _op=$(get_mount_info OPTIONS target $_mp -f)
ddebug "dump_fs _mp=$_mp _opts=$_op"
if ! is_mounted "$_mp"; then
dinfo "dump path \"$_mp\" is not mounted, trying to mount..."
@ -139,8 +140,8 @@ dump_fs()
# Only remount to read-write mode if the dump target is mounted read-only.
if [[ "$_op" = "ro"* ]]; then
dinfo "Mounting Dump target $_dev in rw mode."
mount -o remount,rw $_dev $_mp || return 1
dinfo "Remounting the dump target in rw mode."
mount -o remount,rw $_mp || return 1
fi
mkdir -p $_dump_path || return 1