Problem with setup-storage preserving an existing LVM over RAID volume (workaround)
Christian Meyer
c2h5oh at web.de
Thu Jan 31 19:29:14 CET 2019
Hello Thomas and all,
Am Donnerstag, den 31.01.2019, 10:32 +0100 schrieb Thomas Lange:
> This is a bug we fixed in 5.7.3, see #909318.
> So please try a newer FAI version. But I'm not sure if this will also
> fix your other problems.
Thank you for looking into it. I'm sad that I can't help with perl.
> I'm not sure if anyone ever tried to preserve LVM over RAID and had success.
In the meantime I succeeded with what you suggested 'years ago': I used
a script under class/
My solution is an ugly hack, but it works for both preserving and
deleting an existing LVM over RAID.
So I'm able to just reinstall KVM host (on md0) and keep all the guests
in a LVM-VG on a different RAID. If anyone is trying something similar:
remember to backup your kvm-settings, too, e.g. with 'virsh dumpxml
vmname > vmname.xml' and similar for storage and networking.
This workaround is just for the record, perhaps it is useful for
others:
First I try to mount a previous FAI Installation (this is expected
under /dev/md0 without LVM) and to copy the old disk_config logs:
mdadm --assemble /dev/md0 --force --run /dev/sdb1 /dev/sda1
mount /dev/md0 /mnt
cat /mnt/var/log/fai/localhost/last-install/fstab > $LOGDIR/fstab;
cat /mnt/var/log/fai/localhost/last-install/disk_var.sh >
$LOGDIR/disk_var.sh
grep UUID /mnt/var/log/fai/localhost/last-install/format.log >
$LOGDIR/format.log
umount /mnt
To preserve LVM and RAID I do this:
===================================
[ $(cat $LOGDIR/fstab | wc -l) -gt 0 ] && {
UUID_old=$(grep -P '\t/\t' $LOGDIR/fstab | cut -d\= -f2 | cut -f1)
UUID_new=$(mkfs.ext4 /dev/md0 | tee $LOGDIR/format.log | grep UUID |
cut -d\ -f4)
sed -i -e "s:UUID=$UUID_old:UUID=$UUID_new:" $LOGDIR/disk_var.sh
sed -i -e "s:^UUID=$UUID_old:UUID=$UUID_new:" $LOGDIR/fstab
skiptask partition;
}
To delete the old LVM and RAID I do that:
=========================================
VGs="$(echo $(vgscan | grep "Found volume group" | cut -d\" -f2))"
for VG in $VGs; do
vgchange -an $VG
vgremove -q -y -ff $VG
done
mdadm --stop --scan
for partition in $(for disk in $disklist; do echo $disk | grep -qv md -
&& echo /dev/$disk[1-9]; done); do
mdadm --zero-superblock $partition 2>/dev/null;
done
# (from class/20-hwdetect.sh)
odisklist=$disklist
set_disk_info # recalculate list of available disks
if [ "$disklist" != "$odisklist" ]; then
echo New disklist: $disklist
echo disklist=\"$disklist\" >> $LOGDIR/additional.var
fi
-> continue with regular disk_config (without any 'preserve'-line)
building a new RAID and LVM.
Christian
More information about the linux-fai
mailing list