Introduce get_kdump_mntpoint_from_target and fix duplicated /
User a helper to get the path to mount dump target in kdump kernel, and fix duplicated '/' in the mount path problem. Fixes: bz1785371 Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
parent
539bff4083
commit
43ea36b3e8
19
kdump-lib.sh
19
kdump-lib.sh
@ -258,6 +258,25 @@ get_mntpoint_from_target()
|
||||
findmnt -k -f -n -r -o TARGET --source $1
|
||||
}
|
||||
|
||||
# Get the path where the target will be mounted in kdump kernel
|
||||
# $1: kdump target device
|
||||
get_kdump_mntpoint_from_target()
|
||||
{
|
||||
local _mntpoint=$(get_mntpoint_from_target $1)
|
||||
|
||||
# mount under /sysroot if dump to root disk or mount under
|
||||
# /kdumproot/$_mntpoint in other cases in 2nd kernel. systemd
|
||||
# will be in charge to umount it.
|
||||
if [ "$_mntpoint" = "/" ];then
|
||||
_mntpoint="/sysroot"
|
||||
else
|
||||
_mntpoint="/kdumproot/$_mntpoint"
|
||||
fi
|
||||
|
||||
# strip duplicated "/"
|
||||
echo $_mntpoint | tr -s "/"
|
||||
}
|
||||
|
||||
# get_option_value <option_name>
|
||||
# retrieves value of option defined in kdump.conf
|
||||
get_option_value() {
|
||||
|
7
kdumpctl
7
kdumpctl
@ -480,12 +480,7 @@ check_dump_fs_modified()
|
||||
return 2
|
||||
fi
|
||||
|
||||
if [[ "$_target" = "$(get_root_fs_device)" ]]; then
|
||||
_new_mntpoint="/sysroot"
|
||||
else
|
||||
_new_mntpoint="/kdumproot/$(get_mntpoint_from_target $_target)"
|
||||
fi
|
||||
|
||||
_new_mntpoint="$(get_kdump_mntpoint_from_target $_target)"
|
||||
_dracut_args=$(lsinitrd $TARGET_INITRD -f usr/lib/dracut/build-parameter.txt)
|
||||
if [[ -z "$_dracut_args" ]];then
|
||||
echo "Warning: No dracut arguments found in initrd"
|
||||
|
20
mkdumprd
20
mkdumprd
@ -51,21 +51,12 @@ add_dracut_sshkey() {
|
||||
|
||||
# caller should ensure $1 is valid and mounted in 1st kernel
|
||||
to_mount() {
|
||||
local _dev=$1 _source _target _fstype _options _mntopts _pdev
|
||||
local _dev=$1 _source _new_mntpoint _fstype _options _mntopts _pdev
|
||||
|
||||
_source=$(findmnt -k -f -n -r -o SOURCE $_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.
|
||||
|
||||
if [ "$_target" = "/" ];then
|
||||
_target="/sysroot"
|
||||
else
|
||||
_target="/kdumproot/$_target"
|
||||
fi
|
||||
|
||||
_fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev)
|
||||
_new_mntpoint=$(get_kdump_mntpoint_from_target $_dev)
|
||||
|
||||
[[ -e /etc/fstab ]] && _options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev)
|
||||
if [ -z "$_options" ]; then
|
||||
_options=$(findmnt -k -f -n -r -o OPTIONS $_dev)
|
||||
@ -87,14 +78,13 @@ to_mount() {
|
||||
# mount it before kdump starts, this is an attempt to improve robustness
|
||||
_options="$_options,nofail,x-systemd.before=initrd-fs.target"
|
||||
|
||||
_mntopts="$_target $_fstype $_options"
|
||||
#for non-nfs _dev converting to use udev persistent name
|
||||
_mntopts="$_new_mntpoint $_fstype $_options"
|
||||
# for non-nfs _dev converting to use udev persistent name
|
||||
if [ -b "$_source" ]; then
|
||||
_pdev="$(get_persistent_dev $_source)"
|
||||
if [ -z "$_pdev" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
else
|
||||
_pdev=$_dev
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user