From 91106c16b735227206cb754317dfbcd1308b3152 Mon Sep 17 00:00:00 2001 From: Pratyush Anand Date: Sep 16 2016 07:45:13 +0000 Subject: 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 --- diff --git a/kdump-lib.sh b/kdump-lib.sh index 4567a05..2bf14f8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -174,7 +174,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 594450d..19431e1 100755 --- a/kdumpctl +++ b/kdumpctl @@ -379,9 +379,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