partman-auto-lvm patch
Hi all,
I just finished writing and testing a little patch for partman-auto-lvm to let
it use all available disks in the machine for a single VG.
It can only be used by preseeding for now (partman-auto-lvm/use_all_disks) and
will erase all content in the disks other than the one used "by default".
Reading the code to write this patch lead me to ask why, in
partman-auto/display.d/initial_auto, there's a loop around calls to
autopartition and autopartition-lvm as there can't be more than one disk in
$disks. I've tried to preseed partman-auto/disk with two disks, but the
installer hangs. If anyone here knows I'm really interested about the answer.
Just a last thing : this patch was only tested (for now) using qemu virtual
machines.
Cheers,
Grégory
Index: packages/partman/partman-auto-lvm/lib/auto-lvm.sh
===================================================================
--- packages/partman/partman-auto-lvm/lib/auto-lvm.sh (révision 50853)
+++ packages/partman/partman-auto-lvm/lib/auto-lvm.sh (copie de travail)
@@ -102,8 +102,16 @@
# It will be used later to provide real paths to partitions to LVM.
# (still one atm)
devfspv_devices=''
-
+
create_partitions
+
+ # Search for other disks than the one being partitioned.
+ # As all of their content will be destroyed, the user must preseed
+ # partman-auto-lvm/use_all_disks
+ db_get partman-auto-lvm/use_all_disks
+ if [ -n "$RET" -a "$RET" = true ]; then
+ add_disks_to_lvm $dev
+ fi
if ! confirm_changes partman-lvm; then
return 30
@@ -160,3 +168,42 @@
# Default to accepting the autopartitioning
menudir_default_choice /lib/partman/choose_partition finish finish || true
}
+
+add_disks_to_lvm() {
+ [ -d $1 ] || return 1
+
+ local device dev partitions
+ current_dev=$1
+ device="$(cat $current_dev/device)"
+
+ for dev in $DEVICES/*; do
+ tmp_dev="$(cat $dev/device)"
+ if [ "$tmp_dev" != "$device" ]; then
+ # Destroy everything on the disk
+ create_new_label $dev no
+
+ # Is it needed to call read_paragraph ?
+ # Maybe a simple call to read_line would be enough and
+ # would prevent the while loop.
+ open_dialog PARTITIONS
+ read_paragraph > /tmp/add_disks_to_lvm
+ close_dialog PARTITION_INFO
+
+ while { read num id size type fs path name; [ "$id" ]; }; do
+ if [ $fs = "free" ]; then
+ open_dialog NEW_PARTITION 'primary' ext2 $id 'full' $size
+ read_line numinn idinn sizeinn typeinn fsinn pathinn nameinn
+ close_dialog
+ lvm_devs="$lvm_devs $pathinn"
+ open_dialog COMMIT
+ close_dialog
+ fi
+ done < /tmp/add_disks_to_lvm
+ fi
+ done
+
+ rm /tmp/add_disks_to_lvm
+ devfspv_devices="$devfspv_devices $lvm_devs"
+
+ cd $current_dev
+}
Reply to: