From 1a8a39aa9c9c0e7618a9b89fc340eab1b2334a33 Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Wed, 31 Dec 2014 10:48:59 +0800 Subject: [PATCH] adding the parsed path to etc/kdump.conf of kdump initrd 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 v4->v5: Chaowang suggested using sed command d to remove the whole line like below: sed -i "/^path/d" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf Signed-off-by: Baoquan He Acked-by: WANG Chao Acked-by: Dave Young --- 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..ff7a088 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 "/^path/d" /tmp/$$-kdump.conf + echo "path $_path" >> /tmp/$$-kdump.conf fi }