#1064009 initramfs-tools-core: initrd fails to boot stating root fs is missing with LVM RAID1 in degraded mode

#1064009#5
Date:
2024-02-15 16:32:48 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?
Consider having VM with two ~21.5GB disks and doing fresh installation
Debian installer partitioner setup
1) Created partitions as follows
/dev/vda1   500MB EFI
/dev/vda2   21GB LVM
/dev/vdb1   500MB EFI
/dev/vdb2   21GB LVM

2) Setup LVM as follows
vg_main as VG consists of /dev/vda2 & /dev/vdb2 PVs (~ 2*20GB)
lv_root ext4 10GB LV in vg_main
lv_swap swap 1GB LV in vg_main

Both LVs are created as linear by the installer

3) Finish Debian installation & reboot

4) Boot new system and convert lv_root linear LV to RAID 1
lvconvert --type raid1 vg_main/lv_root -m 1

5) Reboot the machine to ensure it boots and check lvs status
  LV                 VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_root            vg_main rwi-aor---   9.31g                                    100.00
  [lv_root_rimage_0] vg_main iwi-aor---   9.31g
  [lv_root_rimage_1] vg_main iwi-aor---   9.31g
  [lv_root_rmeta_0]  vg_main ewi-aor---   4.00m
  [lv_root_rmeta_1]  vg_main ewi-aor---   4.00m
  lv_swap            vg_main -wi-ao---- 952.00m

6) shutdown the machine, disconnect vdb disk and start it again

7) initrd drops to initramfs shell stating it's unable to find root file system

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

Created a script /etc/initramfs-tools/scripts/local-top/startlvm with the following content
#!/bin/sh
PREREQ=""
prereqs()
{
   echo "$PREREQ"
}
case $1 in
prereqs)
   prereqs
   exit 0
   ;;
esac
. /scripts/functions
# Begin real processing below this line
lvm vgchange -ay --activationmode degraded --sysinit

   * What was the outcome of this action?
LVM was able to start root LV even if one PV was missing.

   * What outcome did you expect instead?
I would expect this to be handled without a need for a custom script.