diff --git a/kdump-lib.sh b/kdump-lib.sh index 8b0516f..5333fe4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -133,9 +133,33 @@ get_fs_type_from_target() echo $(findmnt -k -f -n -r -o FSTYPE $1) } +# input: device path +# output: the general mount point +# find the general mount point, not the bind mounted point in atomic +# As general system, Use the previous code +# +# ERROR and EXIT: +# the device can be umounted the general mount point, if one of the mount point is bind mounted +# For example: +# mount /dev/sda /mnt/ +# mount -o bind /mnt/var /var +# umount /mnt get_mntpoint_from_target() { - echo $(findmnt -k -f -n -r -o TARGET $1) + if is_atomic; then + for _mnt in $(findmnt -k -n -r -o TARGET $1) + do + if ! is_bind_mount $_mnt; then + echo $_mnt + return + fi + done + + echo "Mount $1 firstly, without the bind mode" >&2 + exit 1 + else + echo $(findmnt -k -f -n -r -o TARGET $1) + fi } # get_option_value diff --git a/mkdumprd b/mkdumprd index 7c572a7..14ec70f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -103,7 +103,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev _source=$(findmnt -k -f -n -r -o SOURCE $_dev) - _target=$(findmnt -k -f -n -r -o TARGET $_dev) + _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it. @@ -147,10 +147,6 @@ to_mount() { echo "$_pdev $_mntopts" } -to_mount_point() { - echo $(findmnt -k -f -n -r -o TARGET $1) -} - is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -204,7 +200,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() { - local _mnt=$(to_mount_point $1) + local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}') }