Subject: Re: bug#40999: GRUB prevents booting a degraded RAID1 array atop LUKS

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 04 Mar 2022 22:33:49 -0500

Hi,

I'm writing here because I just found a much easier way to trigger this
than by opening the case of my desktop and pulling a drive out with this
QEMU script:

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env bash

devices=(sda sdb sdc)
args=(-enable-kvm -snapshot -m 2G)

i=0
for d in "${devices[@]}"; do
    args+=(-drive file=/dev/$d,index=$i,media=disk)
    let i++
done

qemu-system-x86_64 "${args[@]}" "$@"
--8<---------------cut here---------------end--------------->8---

This attempts to boot the drives of the *live* system in QEMU; don't
fret, it's not dangerous as the '-snapshot' option ensure no actual
writes reach the drives.  It seems to fail at the mount command in our
initrd, but it at least allow testing GRUB easily.

With the above script and my Btrfs RAIDc3 array on drives /dev/sda,
/dev/sdb and /dev/sdc, after removing 'sdb' from the devices list for
example I get:

--8<---------------cut here---------------start------------->8---
Booting from Hard Disk...
GRUB loading...
Welcome to GRUB!

Attempting to decrypt master key...
Enter passphrase for hd0,gpt2 (0792432c78d84dcc87c530200c3d02db):
Slot 0 opened
error: failure reading sector 0x0 from `fd0'.
error: no such cryptodisk found.
Attempting to decrypt master key...
Enter passphrase for hd1,gpt2 (f0afd5c9da7046a79c6f5d22913638bf):
Slot 0 opened
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
error: failure reading sector 0x80 from `fd0'.
--8<---------------cut here---------------end--------------->8---

Dropping just sdc instead, I get:

--8<---------------cut here---------------start------------->8---
Booting from Hard Disk...
GRUB loading...
Welcome to GRUB!

Attempting to decrypt master key...
Enter passphrase for hd0,gpt2 (0792432c78d84dcc87c530200c3d02db): 
Slot 0 opened
Attempting to decrypt master key...
Enter passphrase for hd1,gpt2 (a9aead409d014f7abb83be70dd192b7b): 
Slot 0 opened
error: failure reading sector 0x0 from `fd0'.
error: no such cryptodisk found.
error: failure reading sector 0x80 from `fd0'.
error: unknown filesystem.
Entering rescue mode...
--8<---------------cut here---------------end--------------->8---

This should make a future fix cheaper to try (but a system test will be
best anyway :-)).

Thanks,

Maxim