The kdump will dump the core in incorrect target directory, if the
target is bind mounted.
The kdump cann't parse the bind mounted path, if we specifies the vale
"path /var/crash" in the /etc/kdump.conf.
To correct dumping target, we can construct the real dumping path, which
contains two part, one bind mounted path, the other specified dump
target.
Following is an example:
-bash-4.2# cat /etc/kdump.conf | grep ^path
path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}'
/dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var]
-bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}'
/dev/mapper/atomicos-root
Then we can found it that the real path of dumping core is
/ostree/deploy/rhel-atomic-host/var/crash.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
dracut-module-setup.sh | 46 +++++++++++++++++++++++++++++++++++++++++++---
mkdumprd | 22 +++++++++++++++++++++-
2 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 477ede1..6a8c631 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -312,7 +312,7 @@ default_dump_target_install_conf()
{
local _target _fstype
local _mntpoint
- local _save_path
+ local _save_path _update_path=0
is_user_configured_dump_target && return
@@ -321,6 +321,18 @@ default_dump_target_install_conf()
_mntpoint=$(get_mntpoint_from_path $_save_path)
_target=$(get_target_from_path $_save_path)
+
+ if is_bind_mount $_mntpoint; then
+ _save_path=$(cut_out_substring $_save_path $_mntpoint)
+ # the real dump path in the 2nd kernel, if the mount point is bind mounted.
+ _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path
+
+ local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path
+
+ _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
+ _update_path=1
+ fi
+
if [ "$_mntpoint" != "/" ]; then
_fstype=$(get_fs_type_from_target $_target)
@@ -333,13 +345,36 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
- _save_path=$(cut_out_substring $_save_path $_mntpoint)
+ if [[ $_update_path = 0 ]]; then
+ _save_path=$(cut_out_substring $_save_path $_mntpoint)
+ _update_path=1
+ fi
+ fi
+ if [[ $_update_path = 1 ]]; then
#erase the old path line, then insert the parsed path
sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf
echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
fi
+}
+adjust_bind_mount_path()
+{
+ local _target=$1
+ local _save_path=$(get_option_value "path")
+ [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
+ local _absolute_save_path=$(get_mntpoint_from_target $config_val)/$_save_path
+ local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
+
+ if is_bind_mount $_mntpoint; then
+ local _path=$(cut_out_substring $_absolute_save_path $_mntpoint)
+ # the real dump path in the 2nd kernel, if the mount point is bind mounted.
+ _path=$(get_bind_mount_directory $_mntpoint)/$_path
+
+ #erase the old path line, then insert the parsed path
+ sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf
+ echo "path $_path" >> ${initdir}/tmp/$$-kdump.conf
+ fi
}
#install kdump.conf and what user specifies in kdump.conf
@@ -353,9 +388,14 @@ kdump_install_conf() {
case "$config_opt" in
ext[234]|xfs|btrfs|minix|raw)
sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt
$(kdump_to_udev_name $config_val)#" ${initdir}/tmp/$$-kdump.conf
+ adjust_bind_mount_path "$config_val"
+ ;;
+ ssh)
+ kdump_install_net "$config_val"
;;
- ssh|nfs)
+ nfs)
kdump_install_net "$config_val"
+ adjust_bind_mount_path "$config_val"
;;
kdump_pre|kdump_post|extra_bins)
dracut_install $config_val
diff --git a/mkdumprd b/mkdumprd
index 7fdcebf..a3378fd 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -359,6 +359,16 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH)
_target=$(get_target_from_path $SAVE_PATH)
+
+ if is_bind_mount $_mntpoint; then
+ SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint)
+ # the real dump path in the 2nd kernel, if the mount point is bind mounted.
+ SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
+
+ local _absolute_save_path=$(get_mntpoint_from_target $_target)/$SAVE_PATH
+ _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
+ fi
+
if [ "$_mntpoint" != "/" ]; then
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint)
_fstype=$(get_fs_type_from_target $_target)
@@ -530,8 +540,18 @@ do
if [ "$config_opt" = "nfs" ]; then
add_dracut_module "nfs"
fi
+
+ _absolute_save_path=$(make_absolute_save_path $config_val)
+ _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
+ if is_bind_mount $_mntpoint; then
+ _bind_dir=$(get_bind_mount_directory $_mntpoint)
+ SAVE_PATH=$(cut_out_substring $SAVE_PATH $_bind_dir)
+ # the real dump path in the 2nd kernel, if the mount point is bind mounted.
+ SAVE_PATH=$_bind_dir/$SAVE_PATH
+ fi
+
add_mount "$config_val"
- check_save_path_fs $(make_absolute_save_path $config_val)
+ check_save_path_fs $_absolute_save_path
check_size fs $config_val
;;
raw)
--
1.9.3