Add more robust removal of LVM on target
Should prevent strange failures to recreate LVM if a previous one existed and no block zeroing is done.
This commit is contained in:
parent
b023596ef6
commit
ccf3c63606
|
@ -552,8 +552,32 @@ else
|
|||
echo "found small disk (${blockdev_size_gbytes} < 100GB), using small partition sizes."
|
||||
fi
|
||||
|
||||
echo -n "Disabing existing volume groups... "
|
||||
vgchange -an >&2 || true
|
||||
echo -n "Unmounting potential partitions on target device... "
|
||||
for mount in $( mount | grep "${target_disk}" | awk '{ print $3 }' | sort -r ); do
|
||||
umount -f ${mount} >&2
|
||||
done
|
||||
echo "done."
|
||||
|
||||
echo -n "Unmounting potential LVM logical volumes on target device... "
|
||||
for vg in $( pvscan | grep "${target_disk}" | awk '{ print $4 }' ); do
|
||||
for mount in $( mount | grep "/${vg}" | awk '{ print $3 }' | sort -r ); do
|
||||
umount -f ${mount} >&2
|
||||
done
|
||||
done
|
||||
echo "done."
|
||||
|
||||
echo -n "Disabing potential LVM volume groups on target device... "
|
||||
for vg in $( pvscan | grep "${target_disk}" | awk '{ print $4 }' ); do
|
||||
vgchange -an ${vg} >&2 || true
|
||||
sleep 1
|
||||
vgchange -an ${vg} >&2
|
||||
done
|
||||
echo "done."
|
||||
|
||||
echo -n "Removing existing LVM physical volumes... "
|
||||
for pv in $( pvcscan | grep "${target_disk}" | awk '{ print $2 }' ); do
|
||||
yes | pvremove ${pv}
|
||||
done
|
||||
echo "done."
|
||||
|
||||
blockcheck() {
|
||||
|
|
Loading…
Reference in New Issue