When using nfs target, kdumpctl will manually resolve nfs server's
hostname. But the problem is nfs service may select another address if
the server have multiple address. eg. nfs will try IPv6 first, then
failover to IPv4.
It's hard to tell if the NFS server is serving nfs service on it's
IPv6 or IPv4 interface or both, things may get even more complex if
the host have multiple address or there are some special routing
rules. Blindly use IPv4 / IPv6 may have poteintial risk. So use the
working address reported by nfs service, which should always work.
---
dracut-module-setup.sh | 12 ++++++++++--
kdump-lib.sh | 10 +++++++++-
mkdumprd | 5 ++---
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 7499678..2637c29 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -479,7 +479,7 @@ adjust_bind_mount_path()
#install kdump.conf and what user specifies in kdump.conf
kdump_install_conf() {
- local _opt _val _pdev
+ local _opt _val _pdev _addr
sed -ne '/^#/!p' /etc/kdump.conf > ${initdir}/tmp/$$-kdump.conf
while read _opt _val;
@@ -498,7 +498,15 @@ kdump_install_conf() {
adjust_bind_mount_path "$_val"
fi
;;
- ssh|nfs)
+ nfs)
+ _addr=$(get_mount_options_from_target "$_val" | sed
's/.*,addr=\([0-9a-f:\.]*\).*/\1/')
+ if [[ -n "$_addr" ]]; then
+ kdump_install_net "$_addr"
+ else
+ kdump_install_net "$_val"
+ fi
+ ;;
+ ssh)
kdump_install_net "$_val"
;;
dracut_args)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 6acab8c..8b4e360 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -236,11 +236,19 @@ get_target_from_path()
echo $_target
}
-get_fs_type_from_target()
+get_fs_type_from_target()
{
echo $(findmnt -k -f -n -r -o FSTYPE $1)
}
+get_mount_options_from_target()
+{
+ local _options
+ [[ -e /etc/fstab ]] && _options=$(findmnt --fstab -f -n -r -o OPTIONS $1)
+ [ -z "$_options" ] && _options=$(findmnt -k -f -n -r -o OPTIONS
$1)
+ echo $_options
+}
+
# input: device path
# output: the general mount point
# find the general mount point, not the bind mounted point in atomic
diff --git a/mkdumprd b/mkdumprd
index 078f988..9c59fef 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -96,9 +96,8 @@ to_mount() {
_target="/kdumproot/$_target"
fi
- _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev)
- [[ -e /etc/fstab ]] && _options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev)
- [ -z "$_options" ] && _options=$(findmnt -k -f -n -r -o OPTIONS
$_dev)
+ _fstype=$(get_fs_type_from_target $_dev)
+ _options=$(get_mount_options_from_target $_dev)
# with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd
# kernel, filter it out here.
_options=$(echo $_options | sed 's/\bnoauto\b//')
--
2.17.1