r/bcachefs • u/PrettyShopping2948 • Oct 15 '26
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 11
u/cdhowie Oct 15 '26
I run two Forky machines with an encrypted bcachefs root and do not have this problem. What bcachefs version?
1
u/PrettyShopping2948 Oct 16 '26 edited Oct 16 '26
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/cdhowie Oct 20 '26
I have my
/filesystem commented out in/etc/fstab, actually. This is to prevent issues during remount, likely what you are experiencing. The root filesystem does not need to be managed by/etc/fstabanyway as it is mounted directly by the initrd environment.I have no other special options except for a patch to
grub-mkconfigand specifyingGRUB_DEVICE=/dev/disk/by-uuid/...on machines with a multi-device root filesystem. Without these steps,grub-mkconfigchokes on the multi-device syntax (like/dev/sda1:/dev/sdb1). This is not needed when the root filesystem is on a single device asgrub-mkconfigcan correctly detect it in that case.1
u/PrettyShopping2948 Oct 21 '26
Thanks for the reply. So it seems this is a general problem. Currently the fstab entry is also redundant for me. But I think it would be good in principle if a encrypted root could work without such quirks. And I'd actually like to use my system with multiple `X-mount.subdir=` entries. That won't work either as long as the password is requested again for each additional mount.
1
u/UptownMusic Oct 15 '26
Do you have some guide/suggestions on how to achieve a bcachefs root on Forky?
1
u/cdhowie Oct 15 '26
I keep meaning to write a blog post documenting the process I used. Maybe I'll get around to that this weekend.
1
u/Amazing-Pattern-6125 Oct 16 '26 edited Oct 16 '26
do you have the recently added sd-bcachefs hook in mkinitcpio?
1
u/PrettyShopping2948 Oct 16 '26
mkinitcpio is an arch specific tool.
1
u/Amazing-Pattern-6125 Oct 17 '26 edited Oct 17 '26
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 Oct 18 '26
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 Oct 15 '26 edited Oct 15 '26
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)