On 12/30/14 at 05:19pm, WANG Chao wrote:
On 12/30/14 at 02:51pm, Baoquan He wrote:
> Steve found a bug. When mount a disk in /var and not specify path
> in /etc/kdump.conf, the vmcore will be dumped into /var/crash of
> that disk, but not /crash on that disk.
>
> This is because when write the parsed path into /tmp/$$-kdump.conf
> in default_dump_target_install_conf() of mkdumprd, it uses below
> sed command. So if no path specified at all, this sed command won't
> add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default
> path, namely "/var/crash" as path if no path in /etc/kdump.conf in
> 2nd kernel.
>
> sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
>
> According to Dave Young's suggestion, erase the old path line and then
> insert the parsed path. This can fix it.
>
> v2->v3:
> erase the old path line and then insert the parsed path.
>
> sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf
> echo "path $_path" >> /tmp/$$-kdump.conf
>
> v3->v4:
> Change the sed pattern, erase lines starting with "path" and then
> insert the parsed path.
>
> sed -i -e "s#^path.*##" /tmp/$$-kdump.conf
> echo "path $_path" >> /tmp/$$-kdump.conf
>
> Signed-off-by: Baoquan He <bhe(a)redhat.com>
> ---
> dracut-module-setup.sh | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 793495a..d0d2d1a 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -331,7 +331,10 @@ default_dump_target_install_conf()
> echo "$_fstype $_target" >> /tmp/$$-kdump.conf
>
> _path=${_save_path##"$_mntpoint"}
> - sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#"
/tmp/$$-kdump.conf
> +
> + #erase the old path line, then insert the parsed path
> + sed -i -e "s#^path.*##" /tmp/$$-kdump.conf
I think next time it's better to use sed -i '/^path/d' to remove the whole
line (including the \n). Anyway I'm not strong with this, but please do next
time.
s#^path.*## will leave a blank line, but /^path/d will delete the line
Agree with you, since we found the problem it is better to do it. Bao, care to resend?
Thanks
Dave