Bug#375491: patch suggestion
patch attached instead
Ronny Aasen
Index: autopartition-lvm
===================================================================
--- autopartition-lvm (revision 40105)
+++ autopartition-lvm (working copy)
@@ -26,10 +26,42 @@
log-output -t update-dev update-dev
fi
+
# Check if the device already contains any physical volumes
realdev=$(mapdevfs "$(cat $dev/device)")
if pv_on_device "$realdev"; then
- bail_out pv_on_device
+ # If we are beeing preseeded with partman-auto-lv/disk, then try to make sure lv's
+ # and vg's are removed from the disk in question.
+ db_get partman-auto-lvm/disk
+ diskseed=$(mapdevfs $RET)
+ if [ "$diskseed" = "$realdev" ] ;then
+ #what volume groups is on any of the the target disk partitions.
+ targetvolumegroups=`pvs --noheading --separator=";" | grep $realdev | cut -d";" -f2`
+ for vgroup in $targetvolumegroups
+ do
+ #make sure the volume groups on the target disk don't span any other disks.
+ if [ "1" -ne `vgs --noheading --separator=";"| grep $vgroup | cut -d";" -f2` ] ;then
+ log-output -t partman-auto-lvs vgs
+ bail_out pv_on_device
+ fi
+ done
+
+ #it should now be safe to remove the vg's on the target disks
+
+ #remove lv's from the target vg's.
+ for vgroup in $targetvolumegroups
+ do
+ for lv in `vgs --noheadings -o lv_name $vgroup`
+ do
+ #remove the logical volumes on the volume group
+ log-output -t partman-auto-lvm lvremove /dev/$vgroup/$lv
+ done
+ #remove the volume group
+ log-output -t partman-auto-lvm vgremove $vgroup
+ done
+ else
+ bail_out pv_on_device
+ fi
fi
choose_recipe "$free_size" lvm || exit $?
Reply to: