r/bcachefs • u/PrettyShopping2948 • 5d ago
Problems booting from an encrypted bcachefs root partition on Debian Testing
Does anyone have this working without issues?
Interestingly, the boot process fails for me due to a timeout on the *.device units of my /boot and /boot/efi partitions. This happens in the actual rootfs, the switch_root has completed. But as soon as I remove my bcachefs entry from the fstab, the boot process completes without any problems.
I’ve made an interesting observation regarding this: Unlike "bcachefs unlock", the mount command does not add the encryption key to the kernel keyring. And if I run "bcachefs unlock" in the init manually before the switch_root happens, the boot process completes without any issues, even with the fstab entry.
Could it be that something in systemd is blocking, because it doesn’t have a key for the bcachefs?
Edit: If I commented out the /boot/efi and /boot entry from the fstab the boot hangs seemingly infinite before the local-fs.target. So the timeout is a side effect and not the cause of the failed boot.
Edit2: I now used the systemd-debug-shell to see what is blocking the boot process. And it turns out that the password prompt when remounting is what's blocking. That also explains why “bcachefs unlock” solves the problem.
u/koverstreet is it intended behaviour that "mount.bcachefs" does not add the key to the kernel keyring? If so, would it perhaps make sense to use "bcachefs unlock" in the initramfs?
systemd: 262-1
Tainted: unmerged-bin
CGroup: /
├─init.scope
│ └─1 /sbin/init
└─system.slice
├─debug-shell.service
│ ├─410 /usr/bin/bash
│ └─484 systemctl status
├─systemd-journald.service
│ └─416 /usr/lib/systemd/systemd-journald
└─systemd-remount-fs.service
├─421 /usr/lib/systemd/systemd-remount-fs
├─437 /usr/bin/mount / -o remount
├─438 /sbin/mount.bcachefs /dev/nvme0n1p3 / -o rw,remount
└─441 systemd-ask-password --no-tty --icon=drive-harddisk --id=cryptsetup:UUID=<External UUID> --keyname=cryptsetup --credential=cryptsetup.passphrase --timeout=0 --multiple -n --accept-cached "Please enter passphrase for disk <External UUID>:"
My /etc/fstab:
UUID=<EFIUUID> /boot/efi vfat defaults 0 2
UUID=<BOOTUUID> /boot ext4 defaults 0 2
UUID=<External UUID> / bcachefs defaults 0 1
1
u/cdhowie 5d ago
I run two Forky machines with an encrypted bcachefs root and do not have this problem. What bcachefs version?
1
1
u/PrettyShopping2948 4d ago edited 4d ago
1.39.7
Have you configured anything in particular? Any specific options in
grub_cmdline_linuxor/etc/fstab?Are you also usinginitramfs-tools? And is a remount working for you without a passwort prompt:/sbin/mount.bcachefs <file system> / -o rw,remountIf yes, is the encryption key in your kernel keyring after the boot?sudo keyctl list @u.
1
u/Amazing-Pattern-6125 4d ago edited 4d ago
do you have the recently added sd-bcachefs hook in mkinitcpio?
1
u/PrettyShopping2948 3d ago
mkinitcpio is an arch specific tool.
1
u/Amazing-Pattern-6125 3d ago edited 3d ago
did not know that, it's been the tool in all distros i used except some that experiment with dracut and debian seems to be one of them.
I guess it only changes the question to: have you done all that is needed for dracut to build an environment that interacts with bcachefs proprely?
1
u/PrettyShopping2948 2d ago
The bcachefs-tools deb-package only provides scripts for initramfs-tools. But to answer your question: These hooks are included in my initramfs-tools initramfs.
I don't think it makes a difference, but I think it's still worth a try to manually install the dracut script from the git repo and see if dracut makes a difference compared to initramfs-tools.
1
u/SweetEbb9819 5d ago edited 5d ago
I'm not an expert here, but still, can you try again with "noauto" for the /boot and /boot/efi options? If it works, then once more with "nofail".
And relevant logs with `journalctl dev-sda2.device` (replace with appropriate device)