On 03/27/2017 at 10:42 AM, Xunlei Pang wrote:
Since the current dracut of Fedora already supports not always
mount the root device, we can remove "root=X" from the cmdline.
If the dump target is not located at root filesystem, will remove
"root=X". It works for us as Feodra has no "--hostonly-cmdline",
otherwise "95rootfs-block" dracut module will generate "root=X"
information in "${initdir}/etc/cmdline.d/95root-dev.conf".
We can easily achieve this by adding a "all_root" job in the
KDUMP_TARGET_CHECKLIST.
We will have only one target mounted in kdump after this patch.
For example, in case of nfs/ssh/usb/etc(non-root) dumping, kdump
will not mount the unnecessary root filesystem after this change,
unless "default dump_to_rootfs" is specified in "/etc/kdump.conf".
Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
---
kdump-lib.sh | 6 ++++++
kdumpctl | 30 +++++++++++++++++++++++++-----
mkdumprd | 6 ------
3 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index d3c0d7b..a003376 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -103,6 +103,12 @@ get_user_configured_dump_disk()
[ -b "$_target" ] && echo $_target
}
+target_is_root() {
+ local _t
+ _t=$(findmnt -k -n -r -o TARGET $1|sort|head -1)
+ [ "$_t" = "/" ]
+}
+
get_root_fs_device()
{
local _target
diff --git a/kdumpctl b/kdumpctl
index e9dc8e5..1cb6f36 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -27,7 +27,7 @@ image_time=0
# implement its logic to update its tag value in the tag inventory.
# Then "kdump_targets_tell xxx" will be available for you to use.
# See kdump_target_handle_item() for examples.
-KDUMP_TARGET_CHECKLIST=""
+KDUMP_TARGET_CHECKLIST="all_root"
standard_kexec_args="-p"
@@ -177,6 +177,11 @@ check_kdump_cpus()
echo " try nr_cpus=$nr_min or larger instead"
}
+is_dump_to_rootfs()
+{
+ grep "^default[[:space:]]dump_to_rootfs" /etc/kdump.conf > /dev/null
+}
+
# This function performs a series of edits on the command line.
# Store the final result in global $KDUMP_COMMANDLINE.
prepare_cmdline()
@@ -205,6 +210,12 @@ prepare_cmdline()
cmdline=`append_cmdline "${cmdline}" disable_cpu_apicid ${id}`
fi
+ # "false" means non-root dump target, then remove "root=X"
+ # unless dump_to_rootfs is specified.
+ if ! kdump_targets_tell all_root && ! is_dump_to_rootfs; then
+ cmdline=`remove_cmdline_param "$cmdline" root`
+ fi
+
KDUMP_COMMANDLINE=$cmdline
check_kdump_cpus
@@ -498,6 +509,13 @@ kdump_target_handle_item()
# The item handling begins
case "$item" in
+ all_root)
+ # Sticky value is 0
+ [[ $value = "0" ]] && return
+
+ value=1
+ target_is_root $dev || value=0
+ ;;
*)
echo "unhandled item in kdump target checklist"
return
@@ -535,10 +553,12 @@ check_kdump_targets()
kdump_target_hook "nfs"
fi
- # Add the root device if needed, currently kdump always mounts the root
- _root=$(get_root_fs_device)
- if [[ -b "$_root" && "$_root" != "$_target" ]];
then
- kdump_target_hook $_root
+ # Add the root device if /etc/kdump.conf has "default dump_to_rootfs"
+ if is_dump_to_rootfs; then
+ _root=$(get_root_fs_device)
+ if [[ -b "$_root" && "$_root" != "$_target" ]];
then
+ kdump_target_hook $_root
+ fi
Currently, I missed the diskless case, I need some discussion about the diskless
environment.
For diskless systems, will "findmnt /" always return the "nfs" mount
information?
Regards,
Xunlei
fi
# NOTE:
diff --git a/mkdumprd b/mkdumprd
index 426149b..d27bf94 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -80,12 +80,6 @@ add_dracut_sshkey() {
add_dracut_arg "--sshkey" "$1"
}
-target_is_root() {
- local _t
- _t=$(findmnt -k -n -r -o TARGET $1|sort|head -1)
- [ "$_t" = "/" ]
-}
-
# caller should ensure $1 is valid and mounted in 1st kernel
to_mount() {
local _dev=$1 _source _target _fstype _options _mntopts _pdev