From 4db9e59e891e4298c2f056b46a01e2343132ee85 Mon Sep 17 00:00:00 2001 From: Pratyush Anand Date: Mon, 12 Sep 2016 12:40:04 +0530 Subject: [PATCH] kdumpctl: fix target identification for systems without initrd We get following error on the systems that have everything built-in and no initrd is used. Kernel dev name of /dev/root is not found. Dump target /dev/root is probably not mounted. It happens because `df $path` gets /dev/root from /proc/self/mountinfo. Fix this by identifying real target device when `df $path` returns Filesystem as /dev/root. Reported-and-tested-by: Michael Holzheu Signed-off-by: Pratyush Anand Acked-by: Dave Young --- kdump-lib.sh | 6 +++++- kdumpctl | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index e594496..406bbc7 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -176,7 +176,11 @@ get_mntpoint_from_path() get_target_from_path() { - echo $(df $1 | tail -1 | awk '{print $1}') + local _target + + _target=$(df $1 2>/dev/null | tail -1 | awk '{print $1}') + [[ "$_target" == "/dev/root" ]] && [[ ! -e /dev/root ]] && _target=$(get_root_fs_device) + echo $_target } get_fs_type_from_target() diff --git a/kdumpctl b/kdumpctl index 019b23a..d0bbb55 100755 --- a/kdumpctl +++ b/kdumpctl @@ -390,9 +390,9 @@ check_dump_fs_modified() _new_fstype=$(blkid $_target | awk -F"TYPE=" '{print $2}' | cut -d '"' -f 2) else _path=$(get_save_path) - set -- $(df -T $_path 2>/dev/null | tail -1 | awk '{ print $1, $2}') - _target=$(to_dev_name $1) - _new_fstype=$2 + _target=$(get_target_from_path $_path) + _target=$(to_dev_name $_target) + _new_fstype=$(get_fs_type_from_target $_target) if [[ -z "$_target" || -z "$_new_fstype" ]];then echo "Dump path $_path does not exist" return 2