Enhance kdump to support bind mounted target, since kdump cann't parse the bind mounted path.
Following is the testcases which kdump can generate the core sucessfully. 1) rootfs, default path / specified path 2) rootfs with bind mounted path which is in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount -o bind /var/crash /mnt/crash 4) rootfs with bind mounted path which is not in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount /dev/vdb /mnt # mount -o bind /var/crash /mnt/crash 5) no-rootfs 6) no-rootfs with bind mounted path which is in the same device 7) no-rootfs with bind mounted path which is not in the same device 8) nfs 9) nfs with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump 10) nfs with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/dump 11) nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump 12) nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/dump 13) ext4 14) ext4 with bind mounted path which is under the ext4 mount point path 15) ext4 with bind mounted path which is not under the ext4 mount point path 16) btrfs 17) btrfs with subvolume which mounts under mount point path 18) btrfs with subvolume which does not mount under mount point path
Minfei Huang (4): kdump-lib: Add new function to cut out the substring kdump-lib: Add the new function to enhance bind mounted judgement kdump-lib: Get the mount point correctly, if the device has several mount point dracut-module-setup: Fix the incorrect dumping target, if the path is bind mounted
dracut-module-setup.sh | 49 +++++++++++++++++++++++++++++++++++----- kdump-lib.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++- mkdumprd | 32 +++++++++++++++++++------- 3 files changed, 128 insertions(+), 14 deletions(-)
It fails to cut out the substring, if the string contains duplicated "/".
Add the new function which it will get the path accurately.
Signed-off-by: Minfei Huang mhuang@redhat.com --- dracut-module-setup.sh | 7 +++---- kdump-lib.sh | 22 ++++++++++++++++++++++ mkdumprd | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4641025..477ede1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,9 +311,8 @@ kdump_install_net() { default_dump_target_install_conf() { local _target _fstype - local _s _t local _mntpoint - local _path _save_path + local _save_path
is_user_configured_dump_target && return
@@ -334,11 +333,11 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
- _path=${_save_path##"$_mntpoint"} + _save_path=$(cut_out_substring $_save_path $_mntpoint)
#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 + echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf fi
} diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b6dcea0 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -188,3 +188,25 @@ is_ipv6_target() _server=${_server:-$_server_tmp} echo $_server | grep -q ":" } + +# fail to cut out the path, if the path contains duplicated "/" +cut_out_substring() +{ + local _prefix_tmp="${initdir}/tmp/$$-kdump-dir" + local _main_str=$_prefix_tmp/$1 _sub_str=$_prefix_tmp/$2 _pwd=`pwd` + + mkdir -p $_main_str + mkdir -p $_sub_str + + cd $_main_str + _main_str=`pwd` + cd $_sub_str + _sub_str=`pwd` + cd $_pwd + + rm -rf $_prefix_tmp + + _main_str=${_main_str#*"$_prefix_tmp"} + _sub_str=${_sub_str#*"$_prefix_tmp"} + echo ${_main_str#*"$_sub_str"} +} diff --git a/mkdumprd b/mkdumprd index 4d251ba..a8f9cbb 100644 --- a/mkdumprd +++ b/mkdumprd @@ -364,7 +364,7 @@ handle_default_dump_target() _mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH) if [ "$_mntpoint" != "/" ]; then - SAVE_PATH=${SAVE_PATH##"$_mntpoint"} + SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target)
if $(is_fs_type_nfs $_fstype); then
On 03/04/15 at 01:07am, Minfei Huang wrote:
It fails to cut out the substring, if the string contains duplicated "/".
Add the new function which it will get the path accurately.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 7 +++---- kdump-lib.sh | 22 ++++++++++++++++++++++ mkdumprd | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4641025..477ede1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,9 +311,8 @@ kdump_install_net() { default_dump_target_install_conf() { local _target _fstype
- local _s _t local _mntpoint
- local _path _save_path
local _save_path
is_user_configured_dump_target && return
@@ -334,11 +333,11 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
_save_path=$(cut_out_substring $_save_path $_mntpoint) #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
echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
Hi Minfei,
Do you remember what's wrong with the duplicate "/"? Why does't it matter in old code?
fi
} diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b6dcea0 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -188,3 +188,25 @@ is_ipv6_target() _server=${_server:-$_server_tmp} echo $_server | grep -q ":" }
+# fail to cut out the path, if the path contains duplicated "/"
This function is not good. I suggest using one line of sed command to do this. This kind of process looks weird.
+cut_out_substring() +{
- local _prefix_tmp="${initdir}/tmp/$$-kdump-dir"
- local _main_str=$_prefix_tmp/$1 _sub_str=$_prefix_tmp/$2 _pwd=`pwd`
- mkdir -p $_main_str
- mkdir -p $_sub_str
- cd $_main_str
- _main_str=`pwd`
- cd $_sub_str
- _sub_str=`pwd`
- cd $_pwd
- rm -rf $_prefix_tmp
- _main_str=${_main_str#*"$_prefix_tmp"}
- _sub_str=${_sub_str#*"$_prefix_tmp"}
- echo ${_main_str#*"$_sub_str"}
+} diff --git a/mkdumprd b/mkdumprd index 4d251ba..a8f9cbb 100644 --- a/mkdumprd +++ b/mkdumprd @@ -364,7 +364,7 @@ handle_default_dump_target() _mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH) if [ "$_mntpoint" != "/" ]; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target) if $(is_fs_type_nfs $_fstype); then
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 04:10pm, Baoquan He wrote:
On 03/04/15 at 01:07am, Minfei Huang wrote:
It fails to cut out the substring, if the string contains duplicated "/".
Add the new function which it will get the path accurately.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 7 +++---- kdump-lib.sh | 22 ++++++++++++++++++++++ mkdumprd | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4641025..477ede1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,9 +311,8 @@ kdump_install_net() { default_dump_target_install_conf() { local _target _fstype
- local _s _t local _mntpoint
- local _path _save_path
local _save_path
is_user_configured_dump_target && return
@@ -334,11 +333,11 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
_save_path=$(cut_out_substring $_save_path $_mntpoint) #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
echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
Hi Minfei,
Do you remember what's wrong with the duplicate "/"? Why does't it matter in old code?
Kdump may fails in the case that we specify the path as "//mnt/var/crash", and mount the device on the point "/mnt". Following is the example.
1) set path=/mnt/var/crash, kdump works well. [root@localhost 99kdumpbase]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Force rebuild /boot/initramfs-3.11.10-301.fc20.x86_64kdump.img Rebuilding /boot/initramfs-3.11.10-301.fc20.x86_64kdump.img + _path=/var/crash + set +x kexec: loaded kdump kernel Starting kdump: [OK]
2) set path=//mnt/var/crash, the target path is incorrect in 2nd kernel. [root@localhost 99kdumpbase]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Force rebuild /boot/initramfs-3.11.10-301.fc20.x86_64kdump.img Rebuilding /boot/initramfs-3.11.10-301.fc20.x86_64kdump.img df: ‘/mnt///mnt/var/crash’: No such file or directory /sbin/mkdumprd: line 239: [: -lt: unary operator expected + _path=//mnt/var/crash + set +x kexec: loaded kdump kernel Starting kdump: [OK]
Since the /mnt is the mount point, the correct path is /var/crash.
fi
} diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b6dcea0 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -188,3 +188,25 @@ is_ipv6_target() _server=${_server:-$_server_tmp} echo $_server | grep -q ":" }
+# fail to cut out the path, if the path contains duplicated "/"
This function is not good. I suggest using one line of sed command to do this. This kind of process looks weird.
I will investigate it, if there is a better way to deal it.
Thanks Minfei
+cut_out_substring() +{
- local _prefix_tmp="${initdir}/tmp/$$-kdump-dir"
- local _main_str=$_prefix_tmp/$1 _sub_str=$_prefix_tmp/$2 _pwd=`pwd`
- mkdir -p $_main_str
- mkdir -p $_sub_str
- cd $_main_str
- _main_str=`pwd`
- cd $_sub_str
- _sub_str=`pwd`
- cd $_pwd
- rm -rf $_prefix_tmp
- _main_str=${_main_str#*"$_prefix_tmp"}
- _sub_str=${_sub_str#*"$_prefix_tmp"}
- echo ${_main_str#*"$_sub_str"}
+} diff --git a/mkdumprd b/mkdumprd index 4d251ba..a8f9cbb 100644 --- a/mkdumprd +++ b/mkdumprd @@ -364,7 +364,7 @@ handle_default_dump_target() _mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH) if [ "$_mntpoint" != "/" ]; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target) if $(is_fs_type_nfs $_fstype); then
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:05pm, Minfei Huang wrote:
On 03/26/15 at 04:10pm, Baoquan He wrote:
+# fail to cut out the path, if the path contains duplicated "/"
This function is not good. I suggest using one line of sed command to do this. This kind of process looks weird.
I will investigate it, if there is a better way to deal it.
It should be like s#/+#/#, it's simpler than yours. Code will be bloated very much if all code is written like below.
Dave might have a precise thought on this, you can consult him.
Thanks Minfei
+cut_out_substring() +{
- local _prefix_tmp="${initdir}/tmp/$$-kdump-dir"
- local _main_str=$_prefix_tmp/$1 _sub_str=$_prefix_tmp/$2 _pwd=`pwd`
- mkdir -p $_main_str
- mkdir -p $_sub_str
- cd $_main_str
- _main_str=`pwd`
- cd $_sub_str
- _sub_str=`pwd`
- cd $_pwd
- rm -rf $_prefix_tmp
- _main_str=${_main_str#*"$_prefix_tmp"}
- _sub_str=${_sub_str#*"$_prefix_tmp"}
- echo ${_main_str#*"$_sub_str"}
+} diff --git a/mkdumprd b/mkdumprd index 4d251ba..a8f9cbb 100644 --- a/mkdumprd +++ b/mkdumprd @@ -364,7 +364,7 @@ handle_default_dump_target() _mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH) if [ "$_mntpoint" != "/" ]; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target) if $(is_fs_type_nfs $_fstype); then
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:10pm, Baoquan He wrote:
On 03/26/15 at 05:05pm, Minfei Huang wrote:
On 03/26/15 at 04:10pm, Baoquan He wrote:
+# fail to cut out the path, if the path contains duplicated "/"
This function is not good. I suggest using one line of sed command to do this. This kind of process looks weird.
I will investigate it, if there is a better way to deal it.
It should be like s#/+#/#, it's simpler than yours. Code will be bloated very much if all code is written like below.
Dave might have a precise thought on this, you can consult him.
Thank you, I will do.
Thanks Minfei
Thanks Minfei
+cut_out_substring() +{
- local _prefix_tmp="${initdir}/tmp/$$-kdump-dir"
- local _main_str=$_prefix_tmp/$1 _sub_str=$_prefix_tmp/$2 _pwd=`pwd`
- mkdir -p $_main_str
- mkdir -p $_sub_str
- cd $_main_str
- _main_str=`pwd`
- cd $_sub_str
- _sub_str=`pwd`
- cd $_pwd
- rm -rf $_prefix_tmp
- _main_str=${_main_str#*"$_prefix_tmp"}
- _sub_str=${_sub_str#*"$_prefix_tmp"}
- echo ${_main_str#*"$_sub_str"}
+} diff --git a/mkdumprd b/mkdumprd index 4d251ba..a8f9cbb 100644 --- a/mkdumprd +++ b/mkdumprd @@ -364,7 +364,7 @@ handle_default_dump_target() _mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH) if [ "$_mntpoint" != "/" ]; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target) if $(is_fs_type_nfs $_fstype); then
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:20pm, Minfei Huang wrote:
On 03/26/15 at 05:10pm, Baoquan He wrote:
On 03/26/15 at 05:05pm, Minfei Huang wrote:
On 03/26/15 at 04:10pm, Baoquan He wrote:
+# fail to cut out the path, if the path contains duplicated "/"
This function is not good. I suggest using one line of sed command to do this. This kind of process looks weird.
I will investigate it, if there is a better way to deal it.
It should be like s#/+#/#, it's simpler than yours. Code will be bloated very much if all code is written like below.
Dave might have a precise thought on this, you can consult him.
Thank you, I will do.
You can try this.
➜ ~ aa="/////aa//bb/c" ➜ ~ echo $aa|sed "s#/{1,}#/#g" /aa/bb/c
On 03/27/15 at 10:13am, Baoquan He wrote:
On 03/26/15 at 05:20pm, Minfei Huang wrote:
On 03/26/15 at 05:10pm, Baoquan He wrote:
On 03/26/15 at 05:05pm, Minfei Huang wrote:
On 03/26/15 at 04:10pm, Baoquan He wrote:
+# fail to cut out the path, if the path contains duplicated "/"
This function is not good. I suggest using one line of sed command to do this. This kind of process looks weird.
I will investigate it, if there is a better way to deal it.
It should be like s#/+#/#, it's simpler than yours. Code will be bloated very much if all code is written like below.
Dave might have a precise thought on this, you can consult him.
Thank you, I will do.
You can try this.
➜ ~ aa="/////aa//bb/c" ➜ ~ echo $aa|sed "s#/{1,}#/#g" /aa/bb/c
Thanks Bao, It works. I will merge it in the next re-post version patch.
Thanks Minfei
findmnt uses the option "-v, --nofsroot" to exclusive the [/dir] in the SOURCE column for bind-mounts, then if $_mntpoint equals to $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
the value of $_mntpoint may be /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the directory is bind mounted. The former part represents the device path, the rest part is the bind mounted directory which quotes by bracket "[]".
Signed-off-by: Minfei Huang mhuang@redhat.com --- kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b6dcea0..74b3c1c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -86,6 +86,38 @@ get_root_fs_device() return }
+# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir] +# in the SOURCE column for bind-mounts, then if $_mntpoint equals to +# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory. +is_bind_mount() +{ + local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}') + local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}') + + if [[ $_mntpoint = $_mntpoint_nofsroot ]]; then + return 1 + else + return 0 + fi +} + +# the value of $_mntpoint will be +# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the +# directory is bind mounted. The former part represents the device path, rest +# part is the bind mounted directory which quotes by bracket "[]". +get_bind_mount_directory() +{ + local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}') + local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}') + + _mntpoint=${_mntpoint#*$_mntpoint_nofsroot} + + _mntpoint=${_mntpoint#[} + _mntpoint=${_mntpoint%]} + + echo $_mntpoint +} + get_mntpoint_from_path() { echo $(df $1 | tail -1 | awk '{print $NF}')
On 03/04/15 at 01:07am, Minfei Huang wrote:
findmnt uses the option "-v, --nofsroot" to exclusive the [/dir] in the SOURCE column for bind-mounts, then if $_mntpoint equals to $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
the value of $_mntpoint may be /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the directory is bind mounted. The former part represents the device path, the rest part is the bind mounted directory which quotes by bracket "[]".
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b6dcea0..74b3c1c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -86,6 +86,38 @@ get_root_fs_device() return }
+# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir] +# in the SOURCE column for bind-mounts, then if $_mntpoint equals to +# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory. +is_bind_mount() +{
- local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
- local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
- if [[ $_mntpoint = $_mntpoint_nofsroot ]]; then
return 1
- else
return 0
- fi
+}
+# the value of $_mntpoint will be +# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the +# directory is bind mounted. The former part represents the device path, rest +# part is the bind mounted directory which quotes by bracket "[]". +get_bind_mount_directory() +{
- local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
- local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
- _mntpoint=${_mntpoint#*$_mntpoint_nofsroot}
- _mntpoint=${_mntpoint#[}
- _mntpoint=${_mntpoint%]}
Here please consider sed command too. it definitely will be simpler. I don't like a big block for only such an action. And the condition checking is very clear for sed command.
- echo $_mntpoint
+}
get_mntpoint_from_path() { echo $(df $1 | tail -1 | awk '{print $NF}') -- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:16pm, Baoquan He wrote:
+# the value of $_mntpoint will be +# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the +# directory is bind mounted. The former part represents the device path, rest +# part is the bind mounted directory which quotes by bracket "[]". +get_bind_mount_directory() +{
- local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
- local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
- _mntpoint=${_mntpoint#*$_mntpoint_nofsroot}
- _mntpoint=${_mntpoint#[}
- _mntpoint=${_mntpoint%]}
Here please consider sed command too. it definitely will be simpler. I don't like a big block for only such an action. And the condition checking is very clear for sed command.
And try this. It's a usual method
-bash-4.2# findmnt /var TARGET SOURCE FSTYPE OPTIONS /var /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var] xfs rw,relat -bash-4.2# findmnt /var| grep "[" | sed "s/(.*)[(.*)](.*)/\2/" /ostree/deploy/rhel-atomic-host/var
On 03/27/15 at 10:53am, Baoquan He wrote:
On 03/26/15 at 05:16pm, Baoquan He wrote:
+# the value of $_mntpoint will be +# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the +# directory is bind mounted. The former part represents the device path, rest +# part is the bind mounted directory which quotes by bracket "[]". +get_bind_mount_directory() +{
- local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
- local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
- _mntpoint=${_mntpoint#*$_mntpoint_nofsroot}
- _mntpoint=${_mntpoint#[}
- _mntpoint=${_mntpoint%]}
Here please consider sed command too. it definitely will be simpler. I don't like a big block for only such an action. And the condition checking is very clear for sed command.
And try this. It's a usual method
-bash-4.2# findmnt /var TARGET SOURCE FSTYPE OPTIONS /var /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var] xfs rw,relat -bash-4.2# findmnt /var| grep "[" | sed "s/(.*)[(.*)](.*)/\2/" /ostree/deploy/rhel-atomic-host/var
Hi, Bao.
The regular expression may fail to filter out the bind mounted path, if the device name has bracket, like "/dev/mapper/atomicos-[root]".
- _mntpoint=${_mntpoint#*$_mntpoint_nofsroot}
Now the $_mntpoint's value is "[/ostree/deploy/rhel-atomic-host/var]", so removing the first '[' and last ']' is ok.
Thanks Minfei
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com --- kdump-lib.sh | 7 ++++++- mkdumprd | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74b3c1c..4301eb4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,12 @@ get_fs_type_from_target()
get_mntpoint_from_target() { - echo $(findmnt -k -f -n -r -o TARGET $1) + for _mnt in $(findmnt -k -n -r -o TARGET $1) + do + if ! is_bind_mount $_mnt; then + echo $_mnt + fi + done }
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev) - _target=$(findmnt -k -f -n -r -o TARGET $_dev) + _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it. @@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() { - echo $(findmnt -k -f -n -r -o TARGET $1) -} - is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() { - local _mnt=$(to_mount_point $1) + local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}') }
Please discard this patch. In mkdumprd we just add the mount info which will mount the needed device. In this stage we don't care the real dump path. Any point is OK, we just need care about the dump path. E.g on Atomic we have below mount point for lvm device. Then current code will take the first one, namely "/". It's fine, we just need dump to /ostree/deploy/rhel-atomic-host/var/crash.
-bash-4.2# findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root / /sysroot /var /usr
On 03/04/15 at 01:07am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 7 ++++++- mkdumprd | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74b3c1c..4301eb4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,12 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; then
echo $_mnt
fi
- done
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:00pm, Baoquan He wrote:
Please discard this patch. In mkdumprd we just add the mount info which will mount the needed device. In this stage we don't care the real dump path. Any point is OK, we just need care about the dump path. E.g on Atomic we have below mount point for lvm device. Then current code will take the first one, namely "/". It's fine, we just need dump to /ostree/deploy/rhel-atomic-host/var/crash.
-bash-4.2# findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root / /sysroot /var /usr
You are right that we can allways get the root mount point in /dev/mapper/atomicos-root in atomic, if we use the command "findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root".
But I think maybe we shall leave the hint how we can get the root mount point correctly, if the target device is not /dev/mapper/atomicos-root, or the os is not atomic. Otherwise it may be hard to be fixed.
Thanks Minfei
On 03/04/15 at 01:07am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 7 ++++++- mkdumprd | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74b3c1c..4301eb4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,12 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; then
echo $_mnt
fi
- done
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:19pm, Minfei Huang wrote:
On 03/26/15 at 05:00pm, Baoquan He wrote:
Please discard this patch. In mkdumprd we just add the mount info which will mount the needed device. In this stage we don't care the real dump path. Any point is OK, we just need care about the dump path. E.g on Atomic we have below mount point for lvm device. Then current code will take the first one, namely "/". It's fine, we just need dump to /ostree/deploy/rhel-atomic-host/var/crash.
-bash-4.2# findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root / /sysroot /var /usr
You are right that we can allways get the root mount point in /dev/mapper/atomicos-root in atomic, if we use the command "findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root".
But I think maybe we shall leave the hint how we can get the root mount point correctly, if the target device is not /dev/mapper/atomicos-root, or the os is not atomic. Otherwise it may be hard to be fixed.
What do you mean? Here the code just do the device mounting. whatever the mount poing is, it will be mounted in 2nd kernel.
And then with the correct dump path, e.g on /dev/sda, it will surely dump to the parsed real dump path on /dev/sda. what is mount point doesn't matter.
Thanks Minfei
On 03/04/15 at 01:07am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 7 ++++++- mkdumprd | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74b3c1c..4301eb4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,12 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; then
echo $_mnt
fi
- done
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:32pm, Baoquan He wrote:
On 03/26/15 at 05:19pm, Minfei Huang wrote:
On 03/26/15 at 05:00pm, Baoquan He wrote:
Please discard this patch. In mkdumprd we just add the mount info which will mount the needed device. In this stage we don't care the real dump path. Any point is OK, we just need care about the dump path. E.g on Atomic we have below mount point for lvm device. Then current code will take the first one, namely "/". It's fine, we just need dump to /ostree/deploy/rhel-atomic-host/var/crash.
-bash-4.2# findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root / /sysroot /var /usr
You are right that we can allways get the root mount point in /dev/mapper/atomicos-root in atomic, if we use the command "findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root".
But I think maybe we shall leave the hint how we can get the root mount point correctly, if the target device is not /dev/mapper/atomicos-root, or the os is not atomic. Otherwise it may be hard to be fixed.
What do you mean? Here the code just do the device mounting. whatever the mount poing is, it will be mounted in 2nd kernel.
And then with the correct dump path, e.g on /dev/sda, it will surely dump to the parsed real dump path on /dev/sda. what is mount point doesn't matter.
The command "findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root" does not always return the "/" firstly. Here is an example.
The directory /crash is a bind mounted directory, and "/mnt" is the mount point of device /dev/vda.
[root@localhost 99kdumpbase]# findmnt -k -n -r -o TARGET /dev/vda /crash /mnt [root@localhost 99kdumpbase]# findmnt /crash TARGET SOURCE FSTYPE OPTIONS /crash /dev/vda[/var/crash] ext4 rw,relatime,seclabel,data=ordered [root@localhost 99kdumpbase]# findmnt /mnt TARGET SOURCE FSTYPE OPTIONS /mnt /dev/vda ext4 rw,relatime,seclabel,data=ordered
If we specify the kdump.conf as following, a warning will be raised in function get_fs_size.
kdump.conf ext4 /dev/vda path /var/crash
The target path is /mnt/var/crash, not the /crash/var/crash.
Thanks Minfei
Thanks Minfei
On 03/04/15 at 01:07am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 7 ++++++- mkdumprd | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74b3c1c..4301eb4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,12 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; then
echo $_mnt
fi
- done
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:48pm, Minfei Huang wrote:
On 03/26/15 at 05:32pm, Baoquan He wrote:
On 03/26/15 at 05:19pm, Minfei Huang wrote: You are right that we can allways get the root mount point in
/dev/mapper/atomicos-root in atomic, if we use the command "findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root".
But I think maybe we shall leave the hint how we can get the root mount point correctly, if the target device is not /dev/mapper/atomicos-root, or the os is not atomic. Otherwise it may be hard to be fixed.
What do you mean? Here the code just do the device mounting. whatever the mount poing is, it will be mounted in 2nd kernel.
And then with the correct dump path, e.g on /dev/sda, it will surely dump to the parsed real dump path on /dev/sda. what is mount point doesn't matter.
Could you paste each mount info of them? I don't get what you mean here about crash and /dev/vda/crash.
The command "findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root" does not always return the "/" firstly. Here is an example.
The directory /crash is a bind mounted directory, and "/mnt" is the mount point of device /dev/vda.
[root@localhost 99kdumpbase]# findmnt -k -n -r -o TARGET /dev/vda /crash /mnt [root@localhost 99kdumpbase]# findmnt /crash TARGET SOURCE FSTYPE OPTIONS /crash /dev/vda[/var/crash] ext4 rw,relatime,seclabel,data=ordered [root@localhost 99kdumpbase]# findmnt /mnt TARGET SOURCE FSTYPE OPTIONS /mnt /dev/vda ext4 rw,relatime,seclabel,data=ordered
If we specify the kdump.conf as following, a warning will be raised in function get_fs_size.
kdump.conf ext4 /dev/vda path /var/crash
The target path is /mnt/var/crash, not the /crash/var/crash.
Thanks Minfei
Thanks Minfei
On 03/04/15 at 01:07am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 7 ++++++- mkdumprd | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74b3c1c..4301eb4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,12 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; then
echo $_mnt
fi
- done
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 03/26/15 at 05:56pm, Baoquan He wrote:
On 03/26/15 at 05:48pm, Minfei Huang wrote:
On 03/26/15 at 05:32pm, Baoquan He wrote:
On 03/26/15 at 05:19pm, Minfei Huang wrote: You are right that we can allways get the root mount point in
/dev/mapper/atomicos-root in atomic, if we use the command "findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root".
But I think maybe we shall leave the hint how we can get the root mount point correctly, if the target device is not /dev/mapper/atomicos-root, or the os is not atomic. Otherwise it may be hard to be fixed.
What do you mean? Here the code just do the device mounting. whatever the mount poing is, it will be mounted in 2nd kernel.
And then with the correct dump path, e.g on /dev/sda, it will surely dump to the parsed real dump path on /dev/sda. what is mount point doesn't matter.
Could you paste each mount info of them? I don't get what you mean here about crash and /dev/vda/crash.
sure.
Here is the mount info for /dev/vda. [root@localhost ~]# mount | grep /dev/vda /dev/vda on /crash type ext4 (rw,relatime,seclabel,data=ordered) /dev/vda on /mnt type ext4 (rw,relatime,seclabel,data=ordered)
The directory tree is: [root@localhost ~]# ls /mnt/ lost+found var [root@localhost ~]# ls /mnt/var/ crash [root@localhost ~]# ls /mnt/var/crash/ [root@localhost ~]#
The command "findmnt -k -n -r -o TARGET /dev/mapper/atomicos-root" does not always return the "/" firstly. Here is an example.
The directory /crash is a bind mounted directory, and "/mnt" is the mount point of device /dev/vda.
[root@localhost 99kdumpbase]# findmnt -k -n -r -o TARGET /dev/vda /crash /mnt [root@localhost 99kdumpbase]# findmnt /crash TARGET SOURCE FSTYPE OPTIONS /crash /dev/vda[/var/crash] ext4 rw,relatime,seclabel,data=ordered
We can see that /crash is a bind mounted direcotry which points to /var/crash.
[root@localhost 99kdumpbase]# findmnt /mnt TARGET SOURCE FSTYPE OPTIONS /mnt /dev/vda ext4 rw,relatime,seclabel,data=ordered
If we specify the kdump.conf as following, a warning will be raised in function get_fs_size.
kdump.conf ext4 /dev/vda path /var/crash
If the kdump.conf is specified like above, the abosolute path for target is /mnt/var/crash.
Thanks Minfei
The target path is /mnt/var/crash, not the /crash/var/crash.
Thanks Minfei
Thanks Minfei
On 03/04/15 at 01:07am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 7 ++++++- mkdumprd | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74b3c1c..4301eb4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,12 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; then
echo $_mnt
fi
- done
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
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@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)
On 03/04/15 at 01:07am, Minfei Huang wrote:
Enhance kdump to support bind mounted target, since kdump cann't parse the bind mounted path.
Following is the testcases which kdump can generate the core sucessfully.
- rootfs, default path / specified path
- rootfs with bind mounted path which is in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount -o bind /var/crash /mnt/crash
- rootfs with bind mounted path which is not in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount /dev/vdb /mnt # mount -o bind /var/crash /mnt/crash
- no-rootfs
- no-rootfs with bind mounted path which is in the same device
- no-rootfs with bind mounted path which is not in the same device
- nfs
- nfs with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump
- nfs with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/dump
- nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump
- nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/dump
- ext4
- ext4 with bind mounted path which is under the ext4 mount point path
- ext4 with bind mounted path which is not under the ext4 mount point path
- btrfs
- btrfs with subvolume which mounts under mount point path
- btrfs with subvolume which does not mount under mount point path
Minfei Huang (4): kdump-lib: Add new function to cut out the substring kdump-lib: Add the new function to enhance bind mounted judgement kdump-lib: Get the mount point correctly, if the device has several mount point dracut-module-setup: Fix the incorrect dumping target, if the path is bind mounted
dracut-module-setup.sh | 49 +++++++++++++++++++++++++++++++++++----- kdump-lib.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++- mkdumprd | 32 +++++++++++++++++++------- 3 files changed, 128 insertions(+), 14 deletions(-)
There's some problems ie. umount original directory and only keep bind mounted one.
The cases looks complicated, I agree with Bao that it increases code complexity dramaticlly so how about do it like below:
1) document that we do not support bind mount 2) for atomic, two ways to resolve the problem: *) they can pack a different kdump.conf with different default path *) we can fix it by conditionally set default path for atomic
Thanks Dave
On 03/09/15 at 01:59pm, Dave Young wrote:
On 03/04/15 at 01:07am, Minfei Huang wrote:
Enhance kdump to support bind mounted target, since kdump cann't parse the bind mounted path.
Following is the testcases which kdump can generate the core sucessfully.
- rootfs, default path / specified path
- rootfs with bind mounted path which is in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount -o bind /var/crash /mnt/crash
- rootfs with bind mounted path which is not in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount /dev/vdb /mnt # mount -o bind /var/crash /mnt/crash
- no-rootfs
- no-rootfs with bind mounted path which is in the same device
- no-rootfs with bind mounted path which is not in the same device
- nfs
- nfs with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump
- nfs with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/dump
- nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump
- nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/dump
- ext4
- ext4 with bind mounted path which is under the ext4 mount point path
- ext4 with bind mounted path which is not under the ext4 mount point path
- btrfs
- btrfs with subvolume which mounts under mount point path
- btrfs with subvolume which does not mount under mount point path
Minfei Huang (4): kdump-lib: Add new function to cut out the substring kdump-lib: Add the new function to enhance bind mounted judgement kdump-lib: Get the mount point correctly, if the device has several mount point dracut-module-setup: Fix the incorrect dumping target, if the path is bind mounted
dracut-module-setup.sh | 49 +++++++++++++++++++++++++++++++++++----- kdump-lib.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++- mkdumprd | 32 +++++++++++++++++++------- 3 files changed, 128 insertions(+), 14 deletions(-)
There's some problems ie. umount original directory and only keep bind mounted one.
Hi, Dave. Since the complicated testcases, we can hold on this patchset, if we are requested to support bind mounted someday.
The cases looks complicated, I agree with Bao that it increases code complexity dramaticlly so how about do it like below:
- document that we do not support bind mount
- for atomic, two ways to resolve the problem: *) they can pack a different kdump.conf with different default path *) we can fix it by conditionally set default path for atomic
Agreed. I think the Atomic should be setted a default path, which points to the /var/crash. And the dumping target never be permitted to change, if the customer wants to dump core correctly.
Thanks Minfei
Thanks Dave