From 60f81e1cd5b9c7f4c3249f1f6e6f2d62d70e6e11 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 2 Mar 2021 17:36:19 -0500 Subject: Fix to make the btrfs install method work. Just figured this out. We must change the fsuid after removing the devices, because btrfs MODIFIES the READ-ONLY SEED DEVICES to mark them unavailable after when remove them from the read-write device. When we reboot with the UNMODIFIED, IMMUTABLE seed image, btrfs cannot handle the duplicate fsuid. We detect this situation (kind of) and call btrfstune -m to change the fsuid of the /dev/mapper/samizdatcrypt single device fs. Now it just works. It would be much better to call this on the booted system on the running rootfs, but btrfs can't, so we instead call it on the initrd mount time. A more proper fix might use the partition table to mark the partition as in need of 'btrfstune -m'. --- src/initrd/btrfs-create.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/initrd/btrfs-create.sh b/src/initrd/btrfs-create.sh index 02ce257..cb415ab 100644 --- a/src/initrd/btrfs-create.sh +++ b/src/initrd/btrfs-create.sh @@ -286,10 +286,14 @@ open_samizdat() fi modprobe btrfs || return btrfs device scan -u || true - btrfs device scan || return - if ! btrfs device ready "$blockdev" + if ! btrfs device scan || ! btrfs device ready "$blockdev" then - : btrfs device ready failed, continuing anyway + devcount=$(btrfs inspect-internal dump-super "$blockdev" | grep -c dev_item.devid) + if [ "$devcount" -eq 1 ] + then + btrfstune -m "$blockdev" + btrfs device ready "$blockdev" || : get used to disappointment + fi fi mount -t btrfs "$blockdev" /root || return samizdat_movemounts "$imgfile" -- cgit v1.2.3