On 2016/04/01 at 09:51, Xunlei Pang wrote:
On 2016/03/30 at 15:45, Pratyush Anand wrote:
> kdump also passes persistent device mapping as --mount or --device argument
> of dracut. However this persistent id (UUID) is changed if dump target is
> re-formated.
> kdumpctl must have a mechanism to recognise this modification, so that its
> service restart is able to rebuild initramfs.
>
> Testing:
> * When raw target is raid device, dracut argument is passed as --device
> '/dev/mapper/xxxxx', and in this case it does not force rebuild after
> reformatting. vmcore save was also fine.
> * When raw target is an ide device, dracut argument is passed as --device
> '/dev/disk/by-uuid/xxxxx', and in this case it does force rebuild after
> reformatting.
> * Similar test was also performed as ext4, xfs and btrfs file system target.
>
> One of the test case's detailed illustration:
> a) Attach an IDE device, lets say it is /dev/sdb1
> b) Format it as ext4
> # mkfs.ext4 /dev/sdb1
> # blkid /dev/sdb1
> /dev/sdb1: UUID="21c7baff-e35d-49c7-aa08-0fba4513f5bf"
TYPE="ext4"
> c) Mount it into /mnt and create a var/crash directory in it.
> # mount /dev/sdb1 /mnt;mkdir /mnt/var;mkdir /mnt/var/crash
> d) Add following line in /etc/kdump.conf
> ext4 /dev/sdb1
> e) Restart kdumpctl
> # kdumpctl restart
Should we make this more intelligent? i.e. open a daemon, if detecting such
modification(poll or better utilize some kernel notification mechanism), then
restart dump automatically without user's manual intervention.
Some further illustration:
Not just for UUID, but also for other kdump-related files, at least
for files, filesystems have the mechanism to notify the changing.
I think it's doable.
Regards,
Xunlei
Regards,
Xunlei
> f) crash
> # echo c > /proc/sysrq-trigger
> g) Here you will be able save vmcore with or without this patch.
> h) repeat step (b), (c), (e) and (f)
> i) Now you will be able to save vmcore only when you have this patch in
> your kexec-tools. Your initramfs will be rebuilt when you repeat step (e)
> after reformatting.
>
> Signed-off-by: Pratyush Anand <panand(a)redhat.com>
> ---
> kdumpctl | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/kdumpctl b/kdumpctl
> index 614a816e344c..060eed1233c5 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -327,10 +327,40 @@ setup_target_initrd()
> fi
> }
>
> +is_dump_target_modified()
> +{
> + target=$(egrep "^ext[234]|^xfs|^btrfs|^raw" /etc/kdump.conf)
> +
> + #if dump target does not exist then do not rebuild
> + [ -n "$target" ] || return 0
> +
> + dracut_args=$(lsinitrd $TARGET_INITRD | grep "Arguments:")
> + #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)
> + uuid=$(blkid $target | awk -F"UUID=" '{print $2}' | cut -d
'"' -f 2)
> + #if target does not have uuid, then also do not rebuild
> + [ -n $uuid ] || return 0
> +
> + echo $dracut_args | grep $uuid &> /dev/null
> + #if dracut argument and target have same uuid, then also do not rebuild
> + [ $? -ne 0 ] || return 0
> +
> + return 1
> +}
> +
> is_system_modified()
> {
> [[ -f $TARGET_INITRD ]] || return 1
>
> + is_dump_target_modified
> + if [ $? -ne 0 ]; then
> + echo "Detected change in dump target"
> + return 1
> + fi
> +
> return 0
> }
>
_______________________________________________
kexec mailing list
kexec(a)lists.fedoraproject.org
http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org