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 in
Atomic, 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 | 39 ++++++++++++++++++++++++++++++++++-----
kdump-lib.sh | 5 +++++
mkdumprd | 24 +++++++++++++++++++++++-
3 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 477ede1..7915b82 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -311,8 +311,7 @@ kdump_install_net() {
default_dump_target_install_conf()
{
local _target _fstype
- local _mntpoint
- local _save_path
+ local _mntpoint _save_path
is_user_configured_dump_target && return
@@ -321,6 +320,17 @@ default_dump_target_install_conf()
_mntpoint=$(get_mntpoint_from_path $_save_path)
_target=$(get_target_from_path $_save_path)
+
+ if is_atomic && 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
+ _mntpoint=$(get_mntpoint_from_target $_target)
+
+ # the absolute path in the 1st kernel
+ _save_path=$_mntpoint/$_save_path
+ fi
+
if [ "$_mntpoint" != "/" ]; then
_fstype=$(get_fs_type_from_target $_target)
@@ -332,14 +342,30 @@ default_dump_target_install_conf()
fi
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
-
_save_path=$(cut_out_substring $_save_path $_mntpoint)
+ fi
+
+ sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf
+ echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
+}
+
+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 $_target)/$_save_path
+ local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
+
+ if is_bind_mount $_mntpoint; then
+ _save_path=$(cut_out_substring $_absolute_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
- #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
-
}
#install kdump.conf and what user specifies in kdump.conf
@@ -353,6 +379,9 @@ 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
+ if is_atomic; then
+ adjust_bind_mount_path "$config_val"
+ fi
;;
ssh|nfs)
kdump_install_net "$config_val"
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 75d7673..8aa0da4 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -237,3 +237,8 @@ cut_out_substring()
local _sub_str=$(echo $2|sed "s#/\{1,\}#/#g")
echo ${_main_str#*"$_sub_str"}
}
+
+is_atomic()
+{
+ grep -q "ostree" /proc/cmdline
+}
diff --git a/mkdumprd b/mkdumprd
index 7fdcebf..d7d006f 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -359,6 +359,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH)
_target=$(get_target_from_path $SAVE_PATH)
+
+ if is_atomic && 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
+ _mntpoint=$(get_mntpoint_from_target $_target)
+
+ # the absolute path in the 1st kernel
+ SAVE_PATH=$_mntpoint/$SAVE_PATH
+ fi
+
if [ "$_mntpoint" != "/" ]; then
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint)
_fstype=$(get_fs_type_from_target $_target)
@@ -530,8 +541,19 @@ do
if [ "$config_opt" = "nfs" ]; then
add_dracut_module "nfs"
fi
+
+ _absolute_save_path=$(make_absolute_save_path $config_val)
+ if is_atomic; then
+ _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
+ if is_bind_mount $_mntpoint; then
+ SAVE_PATH=$(cut_out_substring $_absolute_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
+ fi
+ 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