On 03/31/2017 at 02:15 PM, Dave Young wrote:
On 03/30/17 at 04:10pm, Xunlei Pang wrote:
> Since the current dracut of Fedora already supports not always
> mounting root device, we can remove "root=X" from the command
> line directly, and always get the dump target specified in
> "/etc/kdump.conf" and mount it. If the dump target is located
> at root filesystem, we will add the root mount info explicitly
> from kdump side instead of from dracut side.
>
> For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
> kdump will not mount the unnecessary root fs after this change.
>
> This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
> (if "default dump_to_rootfs" is specified, don't remove
"root=X"),
> and mounts non-root target under "/kdumproot", the root target
> still under "/sysroot"(to be align with systemd sysroot.mount).
>
> After removing "root=X", we now add root fs mount information
> explicitly from the kdump side.
>
> Changed check_dump_fs_modified() a little to avoid rebuild when
> dump target is root, since we add root fs mount explicitly now.
>
> Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
> ---
> kdumpctl | 33 ++++++++++++++++++++++++++++-----
> mkdumprd | 29 +++++++++--------------------
> 2 files changed, 37 insertions(+), 25 deletions(-)
>
> diff --git a/kdumpctl b/kdumpctl
> index 01a2ad8..0fb5e7b 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -171,6 +171,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()
> @@ -192,6 +197,19 @@ prepare_cmdline()
> # These params can be removed configurably
> cmdline=`remove_cmdline_param "$cmdline" ${KDUMP_COMMANDLINE_REMOVE}`
>
> + # Always remove "root=X", as we now explicitly generate all kinds
> + # of dump target mount information including root fs. But we keep
> + # it if "default dump_to_rootfs" is specified(non-root dumping).
> + #
> + # We do this before KDUMP_COMMANDLINE_APPEND, if one really care
> + # about it(e.g. for debug purpose), then can pass "root=X" using
> + # KDUMP_COMMANDLINE_APPEND.
> + #
> + # Don't remove "root=X" in case of fadump?
> + if [ $DEFAULT_DUMP_MODE = "kdump" ] && ! is_dump_to_rootfs; then
> + cmdline=`remove_cmdline_param "$cmdline" root`
> + fi
> +
> cmdline="${cmdline} ${KDUMP_COMMANDLINE_APPEND}"
>
> id=`get_bootcpu_initial_apicid`
> @@ -512,11 +530,16 @@ check_dump_fs_modified()
> fi
> fi
>
> - if ! findmnt $_target >/dev/null; then
> - echo "Dump target $_target is probably not mounted."
> - return 2
> - fi
> - _new_mntpoint="/kdumproot/$(get_mntpoint_from_target $_target)"
> + if ! findmnt $_target >/dev/null; then
> + echo "Dump target $_target is probably not mounted."
> + return 2
> + fi
> +
> + if [[ "$_target" = "$(get_root_fs_device)" ]]; then
> + _new_mntpoint="/sysroot"
> + else
> + _new_mntpoint="/kdumproot/$(get_mntpoint_from_target $_target)"
> + fi
>
> _dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1)
> if [[ -z "$_dracut_args" ]];then
> diff --git a/mkdumprd b/mkdumprd
> index f30d9c2..5a25853 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
> @@ -247,13 +241,13 @@ verify_core_collector() {
> }
>
> add_mount() {
> - if ! target_is_root "$1"; then
> - local _mnt=$(to_mount "$1")
> - if [ $? -ne 0 ]; then
> - exit 1
> - fi
> - add_dracut_mount "$_mnt"
> + local _mnt=$(to_mount "$1")
> +
> + if [ $? -ne 0 ]; then
> + exit 1
> fi
> +
> + add_dracut_mount "$_mnt"
If we add root as default dump target, but we have also "default
dump_to_rootfs" then we will have both root= and the extra dracut mount
item, will this be a problem?
I've verified this case, it doesn't matter.
On the other hand it's odd to turn on "dump_to_rootfs" for a root dump
target.
So I think it is fine on this point.
Regards,
Xunlei
> }
>
> get_block_dump_target()
> @@ -274,7 +268,6 @@ handle_default_dump_target()
> {
> local _target
> local _mntpoint
> - local _fstype
>
> is_user_configured_dump_target && return
>
> @@ -293,13 +286,9 @@ handle_default_dump_target()
> SAVE_PATH=$_mntpoint/$SAVE_PATH
> fi
>
> - if [ "$_mntpoint" != "/" ]; then
> - SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
> - _fstype=$(get_fs_type_from_target $_target)
> -
> - add_mount "$_target"
> - check_size fs $_target
> - fi
> + SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
> + add_mount "$_target"
> + check_size fs $_target
> }
>
> get_default_action_target()
> --
> 1.8.3.1
> _______________________________________________
> kexec mailing list -- kexec(a)lists.fedoraproject.org
> To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
Thanks
Dave