]> xenbits.xensource.com Git - osstest.git/commitdiff
ts-host-install,preseed_create: Do lvm vgextend at install time
authorAnthony PERARD <anthony.perard@citrix.com>
Wed, 25 Oct 2023 12:55:00 +0000 (13:55 +0100)
committerAnthony PERARD <anthony.perard@citrix.com>
Thu, 28 Mar 2024 16:51:52 +0000 (16:51 +0000)
When there's more than one disk, like the "pinot?" machine, the name
assigned to e.g. "sda" may change after a reboot, at least when
installing Debian Bookworm, which is using Linux 6.1.

I believe Linux probes disk controller in parallel and assign "sda"
to the first controller to respond, or something like that, so disk
aren't assigned a name in a predictable order.

So, instead of extending lvm volume group to a new disk on reboot, do
that at install time when we know that lvm is on sda.

Alternatively, we could try to set "d-i partman-auto/disk" with a list
of all disk, but that would mean knowing all the disk before starting
the machine.

This new shell script in /lib/partman/finish.d/ should work in all
debian, so replace the script in ts-host-install by this new one.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Osstest/Debian.pm
ts-host-install

index 98b2fc863d1a38e02cfe0642df67dd0a95f9884b..14ec2293e7999db568804ca7337ab530f879a6dc 100644 (file)
@@ -1312,6 +1312,27 @@ echo ===
 set +e
 ls -l /dev/sd*
 true
+END
+
+    # Extend lvm vg to other disks
+    preseed_hook_installscript($ho, $sfx,
+          '/lib/partman/finish.d', '99extend-vg', <<END, 0);
+#!/bin/sh
+set -ex
+
+log () {
+    logger -t extend-vg-\$\$ "\$\@"
+}
+
+vgname="\$(hostname)-vg"
+devices="\$(sed -nE 's/^[[:space:]]*[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+([sh]d[b-z])[[:space:]]*\$/\\1/p' /proc/partitions)"
+
+for dev in \$devices; do
+    log "Extend \$vgname to \$dev"
+    pvcreate /dev/\$dev
+    vgextend \$vgname /dev/\$dev
+done
+log done
 END
 
     my $dtbs = "$d_i/dtbs.tar.gz";
index 43ed9285dbfced1469e579817e7460f3719096dd..17a1bf789d3a2ff01614ee8bb009467985691a8a 100755 (executable)
@@ -116,15 +116,6 @@ END
         target_cmd_root($ho, "lvremove -f $1");
     }
 
-    my $partitions= target_cmd_output_root($ho, 'cat /proc/partitions');
-    foreach my $l (split /\n/, $partitions) {
-        logm("| $l");
-        next unless $l =~ m/^\s*\d+\s+\d+\s+\d+\s+((?:sd|hd)[b-z])\s*$/;
-        my $dev= "/dev/$1";
-        target_cmd_root($ho, "pvcreate $dev");
-        target_cmd_root($ho, "vgextend $vgname $dev");
-    }
-
     my $kpath= $c{TestHostKeypairPath};
     my $kleaf= $kpath;
     $kleaf =~ s,.*/,,;