[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#621118: partman-auto-lvm: "error creating group" using a preseed recipe with 2 PV on the same disk



Package: partman-auto-lvm
Version: 59ubuntu3
Followup-For: Bug #621118

I've had this problem as well (with the installer for ubuntu bionic).

The problem in my case, where I was trying to create a VG for each PV
/dev/sda3 and /dev/sda4, was most easily fixed by modifying partman-auto-lvm's
lib/auto-lvm.sh per the attached.

First thing to note is that your preseed file *has* to specify that one
of the VG's that you configure up with `vg_name` is set to be the one
that partman-auto-lvm will use as "@DEFAULT@" (`defvgname`, in the
script), like so:

d-i partman-auto-lvm/new_vg_name string ${one of the vg_names}

; otherwise, partman-auto-lvm will default to creating a new VG with a
name either taken from the hostname or "debian" (or "ubuntu", in my
case) and, when your recipe leaves no free PVs, it will croak, which is
what the original poster encountered. But, even accounting for that,
partman-auto-lvm will make duplicate PV assignments.

But, assuming you then have a recipe containing

    ... method{ lvm } vg_name { one of the vg_names }

    ... method{ lvm } vg_name{ another of the vg_names }

then the attached patch will keep from making duplicate assignments
on the same disk.

(To explain briefly, instead of just grabbing any PV and then ending
up with duplicate assignments, it checks the contents of
/var/lib/partman/auto_lvm_map/* and makes sure it's not choosing a PV
that's already been assigned. It's not foolproof, by any means, but it
worked for me, at least, and was easier to finagle into my boot process
[using a `partman/early_command` which overwrote /lib/partman/lib/auto-lvm.sh
in the installer image with my variant by echo-ing each line individually,
a la `{ echo 'line 1'; echo 'line 2'; ...; } > /lib/partman/lib/auto-lvm.sh`,
with `'\''` in place of every embedded single quote. Ugh. Not recommended
for regular use, but terraform handled the details])
--- b/lib/auto-lvm.sh	2017-01-26 16:31:57.000000000 -0500
+++ a/lib/auto-lvm.sh	2022-02-14 17:35:24.331012601 -0500
@@ -45,6 +45,7 @@
 # temporary name is stored into $DEFAULT_VG.
 auto_lvm_create_vg_map() {
 	local pv_device line recipe_device vg_name vg_file pv_device pv_found
+	local pv_found_in_other_map
 
 	rm -rf $VG_MAP_DIR
 	mkdir -p $VG_MAP_DIR
@@ -71,14 +72,23 @@
 
 		# Find the device for this PV from the list of known PVs
 		pv_found=
+		pv_found_in_other_map=
 		for pv_device in $pv_devices; do
 			if echo $pv_device | grep -q "$recipe_device[[:digit:]]*"; then
+				if grep -q "^$pv_device$" $VG_MAP_DIR/*; then
+					pv_found_in_other_map=$pv_device
+				else
+					pv_found=1
+					break
+				fi
-				pv_found=1
-				break
 			fi
 		done
 		if [ "$pv_found" ]; then
 			echo $pv_device >> $VG_MAP_DIR/$vg_name
+		elif [ "$pv_found_in_other_map" ]; then
+			# XXX no error message for this so just die
+			# without providing a clue
+			bail_out no_such_pv
 		else
 			bail_out no_such_pv
 		fi

Reply to: