diff --git a/templates/install.sh b/templates/install.sh index ae1284a..496f398 100755 --- a/templates/install.sh +++ b/templates/install.sh @@ -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() {