On 03/12/20 at 02:20pm, Kairui Song wrote:
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(a)redhat.com>
---
kdump-lib.sh | 19 +++++++++++++++++++
kdumpctl | 7 +------
mkdumprd | 20 +++++---------------
3 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 9c41439..d27aa3b 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -285,6 +285,25 @@ get_mntpoint_from_target()
fi
}
+# Get the path where the target will be mounted in kdump kernel
+# $1: kdump target device
+get_kdump_path_from_target()
Probably get_kdump_mntpoint_from_target is longer but sounds better?
path is misleading because we have path which means "/var/crash" etc.
+{
+ 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
I remember we do not depend on root logic like 1st kernel code in
dracut, that means every fs is equal for kdump initrd. Not sure if it
is good to just drop /sysroot part, any risk for fadump?
+
+ # strip duplicated "/"
+ echo $_mntpoint | tr -s "/"
+}
+
# get_option_value <option_name>
# retrieves value of option defined in kdump.conf
get_option_value() {
diff --git a/kdumpctl b/kdumpctl
index 88128a3..594f99d 100755
--- a/kdumpctl
+++ b/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_path_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"
diff --git a/mkdumprd b/mkdumprd
index b46fd32..c6a0586 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -54,21 +54,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_path_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)
@@ -88,14 +79,13 @@ to_mount() {
# only mount the dump target when needed.
_options="$_options,noauto"
- _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
--
2.24.1
_______________________________________________
kexec mailing list -- kexec(a)lists.fedoraproject.org
To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org