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(a)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