If a disk is mounted on /var/crash, and is changed from /dev/diskA to /dev/diskB then rebuild. If /var/crash and / have been mounted on same disk but now a different disk is mounted at /var/crash then also rebuild.
Signed-off-by: Pratyush Anand panand@redhat.com --- This patch would apply on top of series "kdumpctl: force rebuild when dump target is modified".
Some testing after this patch:
[root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change(s) in the following file(s):
/etc/kdump.conf Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# egrep -v '^#' /etc/kdump.conf
path /var/crash [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# mount /dev/sdc1 /var/crash/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# umount /var/crash [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# mount /dev/sdc1 /var/crash/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# umount /var/crash [root@localhost panand]# mount /dev/sdb1 /var/crash/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] core_collector makedumpfile -l --message-level 1 -d 31 [root@localhost panand]# umount /var/crash
Change kdump.conf to dump in ext4 target
[root@localhost panand]# egrep -v '^#' /etc/kdump.conf
ext4 /dev/sdb1 path /var/crash core_collector makedumpfile -l --message-level 1 -d 31 [root@localhost panand]# mount /dev/sdb1 /mnt/;mkdir /mnt/var;mkdir /mnt/var/crash [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change(s) in the following file(s):
/etc/kdump.conf Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# umount /dev/sdb1;mount /dev/sdb1 /mnt/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# umount /dev/sdb1;mkfs.ext4 /dev/sdb1;mount /dev/sdb1 /mnt/;mkdir /mnt/var;mkdir /mnt/var/crash mke2fs 1.42.13 (17-May-2015) /dev/sdb1 contains a ext4 file system last mounted on Thu Apr 21 10:56:33 2016 Proceed anyway? (y,n) y Discarding device blocks: done Creating filesystem with 5242624 4k blocks and 1310720 inodes Filesystem UUID: 29c6c988-3137-418c-a3a7-4cc9490d69e9 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
[root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK]
kdumpctl | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 30832424562a..2ce00899a1e4 100755 --- a/kdumpctl +++ b/kdumpctl @@ -359,25 +359,44 @@ is_files_modified() return 0 }
+# if a device different than root device is mounted at $path then echo +# the name of mounted device +path_mount_device() +{ + local _path _mnt + + _path=$(get_save_path) + #check if _path's mount point is root ("/") + _mnt=$(df $_path 2>/dev/null | tail -1 | awk '{ print $NF }') + if [[ "$_mnt" != "/" ]]; then + echo $(df $_path 2>/dev/null | tail -1 | awk '{ print $1 }') + fi +} + is_fs_uuid_changed() { local _target _dracut_args _uuid
_target=$(egrep "^ext[234]|^xfs|^btrfs" /etc/kdump.conf)
- #if dump target does not exist then do not rebuild - [[ -n "$_target" ]] || return 0 - _dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1) if [[ -z "$_dracut_args" ]];then echo "Warning: No dracut arguments found in initrd" return 0 fi - #if --mount or --device is not by UUID, then also do not rebuild - echo $_dracut_args | grep "by-uuid" &> /dev/null - [[ $? -eq 0 ]] || return 0
- _target=$(echo $_target | cut -d ' ' -f 2) + # if dump target does not exist, and dump path's mount point is same + # as that of root then do not rebuild + if [[ -n "$_target" ]]; then + _target=$(echo $_target | cut -d ' ' -f 2) + else + _target=$(path_mount_device) + fi + if [[ -z "$_target" ]]; then + echo $_dracut_args | grep "by-uuid" &> /dev/null + [[ $? -eq 0 ]] || return 0 + fi + _uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2) if [[ -z "$_uuid" ]];then echo "Warning: UUID is not present"
On 04/21/16 at 11:16am, Pratyush Anand wrote:
If a disk is mounted on /var/crash, and is changed from /dev/diskA to /dev/diskB then rebuild. If /var/crash and / have been mounted on same disk but now a different disk is mounted at /var/crash then also rebuild.
Thanks for so quick response. A tiny bit concern about patch log, here /var/crash is a default dump path, which is a specific name. User could specify their own favorite place which is different than /var/crash, and meantime doesn't specify target, this patch can also fix it. It may be better to use "dump path" which is a general. My personal opinion. It's up to you and fedora maintainer - Dave.
Patch is great.
Thanks Baoquan
Signed-off-by: Pratyush Anand panand@redhat.com
This patch would apply on top of series "kdumpctl: force rebuild when dump target is modified".
Some testing after this patch:
[root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change(s) in the following file(s):
/etc/kdump.conf Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# egrep -v '^#' /etc/kdump.conf
path /var/crash [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# mount /dev/sdc1 /var/crash/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# umount /var/crash [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# mount /dev/sdc1 /var/crash/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# umount /var/crash [root@localhost panand]# mount /dev/sdb1 /var/crash/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] core_collector makedumpfile -l --message-level 1 -d 31 [root@localhost panand]# umount /var/crash
Change kdump.conf to dump in ext4 target
[root@localhost panand]# egrep -v '^#' /etc/kdump.conf
ext4 /dev/sdb1 path /var/crash core_collector makedumpfile -l --message-level 1 -d 31 [root@localhost panand]# mount /dev/sdb1 /mnt/;mkdir /mnt/var;mkdir /mnt/var/crash [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change(s) in the following file(s):
/etc/kdump.conf Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# umount /dev/sdb1;mount /dev/sdb1 /mnt/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# umount /dev/sdb1;mkfs.ext4 /dev/sdb1;mount /dev/sdb1 /mnt/;mkdir /mnt/var;mkdir /mnt/var/crash mke2fs 1.42.13 (17-May-2015) /dev/sdb1 contains a ext4 file system last mounted on Thu Apr 21 10:56:33 2016 Proceed anyway? (y,n) y Discarding device blocks: done Creating filesystem with 5242624 4k blocks and 1310720 inodes Filesystem UUID: 29c6c988-3137-418c-a3a7-4cc9490d69e9 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
[root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System UUID Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK]
kdumpctl | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 30832424562a..2ce00899a1e4 100755 --- a/kdumpctl +++ b/kdumpctl @@ -359,25 +359,44 @@ is_files_modified() return 0 }
+# if a device different than root device is mounted at $path then echo +# the name of mounted device +path_mount_device() +{
- local _path _mnt
- _path=$(get_save_path)
- #check if _path's mount point is root ("/")
- _mnt=$(df $_path 2>/dev/null | tail -1 | awk '{ print $NF }')
- if [[ "$_mnt" != "/" ]]; then
echo $(df $_path 2>/dev/null | tail -1 | awk '{ print $1 }')
- fi
+}
is_fs_uuid_changed() { local _target _dracut_args _uuid
_target=$(egrep "^ext[234]|^xfs|^btrfs" /etc/kdump.conf)
#if dump target does not exist then do not rebuild
[[ -n "$_target" ]] || return 0
_dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1) if [[ -z "$_dracut_args" ]];then echo "Warning: No dracut arguments found in initrd" return 0 fi
#if --mount or --device is not by UUID, then also do not rebuild
echo $_dracut_args | grep "by-uuid" &> /dev/null
[[ $? -eq 0 ]] || return 0
_target=$(echo $_target | cut -d ' ' -f 2)
- # if dump target does not exist, and dump path's mount point is same
- # as that of root then do not rebuild
- if [[ -n "$_target" ]]; then
_target=$(echo $_target | cut -d ' ' -f 2)
- else
_target=$(path_mount_device)
- fi
- if [[ -z "$_target" ]]; then
echo $_dracut_args | grep "by-uuid" &> /dev/null
[[ $? -eq 0 ]] || return 0
- fi
- _uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2) if [[ -z "$_uuid" ]];then echo "Warning: UUID is not present"
-- 2.5.0 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Hi Bao,
On 21/04/2016:02:28:48 PM, Baoquan He wrote:
On 04/21/16 at 11:16am, Pratyush Anand wrote:
If a disk is mounted on /var/crash, and is changed from /dev/diskA to /dev/diskB then rebuild. If /var/crash and / have been mounted on same disk but now a different disk is mounted at /var/crash then also rebuild.
Thanks for so quick response. A tiny bit concern about patch log, here /var/crash is a default dump path, which is a specific name. User could specify their own favorite place which is different than /var/crash, and meantime doesn't specify target, this patch can also fix it. It may be better to use "dump path" which is a general. My personal opinion. It's up to you and fedora maintainer - Dave.
Patch is great.
Thanks :-)
Agreed, commit log can be improved. If there would not be any comment then I will send V2 with improved log. Will wait for some time for other review comments.
~Pratyush
On 04/21/16 at 12:11pm, Pratyush Anand wrote:
Hi Bao,
On 21/04/2016:02:28:48 PM, Baoquan He wrote:
On 04/21/16 at 11:16am, Pratyush Anand wrote:
If a disk is mounted on /var/crash, and is changed from /dev/diskA to /dev/diskB then rebuild. If /var/crash and / have been mounted on same disk but now a different disk is mounted at /var/crash then also rebuild.
Thanks for so quick response. A tiny bit concern about patch log, here /var/crash is a default dump path, which is a specific name. User could specify their own favorite place which is different than /var/crash, and meantime doesn't specify target, this patch can also fix it. It may be better to use "dump path" which is a general. My personal opinion. It's up to you and fedora maintainer - Dave.
Patch is great.
Thanks :-)
Agreed, commit log can be improved. If there would not be any comment then I will send V2 with improved log. Will wait for some time for other review comments.
Sounds great, thanks! :)
~Pratyush _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
On Thu, Apr 21, 2016 at 1:05 PM, Baoquan He bhe@redhat.com wrote:
On 04/21/16 at 12:11pm, Pratyush Anand wrote:
Hi Bao,
On 21/04/2016:02:28:48 PM, Baoquan He wrote:
On 04/21/16 at 11:16am, Pratyush Anand wrote:
If a disk is mounted on /var/crash, and is changed from /dev/diskA to /dev/diskB then rebuild. If /var/crash and / have been mounted on same disk but now a different disk is mounted at /var/crash then also rebuild.
Thanks for so quick response. A tiny bit concern about patch log, here /var/crash is a default dump path, which is a specific name. User could specify their own favorite place which is different than /var/crash, and meantime doesn't specify target, this patch can also fix it. It may be better to use "dump path" which is a general. My personal opinion. It's up to you and fedora maintainer - Dave.
Patch is great.
Thanks :-)
Agreed, commit log can be improved. If there would not be any comment then I will send V2 with improved log. Will wait for some time for other review comments.
Sounds great, thanks! :)
I merged these changes as well in V5 of "kdumpctl: force rebuild when dump target is modified" series.
~Pratyush