Hello

I have written a patch that i hope could help on this issue.
it can probably be santized, or rewritten in a better way, but it works for me as it looks now.

what it does is basicaly.
it checks that it's beeing run preseeded, if not it does nothing.
if the lvm check finds lvm volumes on the disk, it will check that these volume groups are not spanning multiple disks, if they do it will fail with the same error as before. if it finds that the vg is isolated to the disk, preseeded to be erased, it removes all Logicalvolumes, and VolumeGroups on that disk.


Ronny Aasen


=== patch ====
[EMAIL PROTECTED]:~/svn/partman/partman-auto-lvm$ svn diff
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 $?



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to