Prevent boot failures for encrypted rootfs on top of a degraded array
Hi cryptsetup maintainers, we currently have a situation in which cryptroot fails to decrypt rootfs if on top of a degraded md array. What happens is that mdadm by default only starts degraded arrays after some attempts on local-block stage, whereas cryptroot tries to decrypt volumes only on local-top.
The hereby proposed patch resolves such issue by implementing a retry mechanism in cryptroot scripts. There are multiple reports of such issue; in Debian we have bug #933059 (to which I'll respond attaching this patch, for a broader audience). Also, we have multiple Ubuntu bugs related to that, summarized in: https://bugs.launchpad.net/ubuntu/+source/cryptsetup/+bug/1879980
Thanks in advance for reviews! Cheers,
Guilherme
Below, the commit description:
Currently, cryptsetup try mounting encrypted rootfs only in local-top, failing if not possible. Hence cases like LUKS on top of RAID1 (if the array is degraded) cannot work properly.
This patch allows cryptsetup to retry on local-block stage, relying in a heuristic based on ROOTDELAY and on initramfs looping at local-block phase. We also added a script to local-bottom stage in order to clean some control files used to track progress in local-block.
The tests with Debian Buster were successful; we created RAID1 and a LUKS volume on top of it, to hold the rootfs. By removing one disk of RAID1, we fail to boot without the patch (initramfs-tools drops into a shell), whereas with the patch we have the boot succeeding.
Signed-off-by: Guilherme G. Piccoli gpiccoli@canonical.com