bcachefs/rootfs
bcachefs support is currently in its experimental stages in Gentoo and the Kernel so dragons beware! Please report Kernel issues upstream.
This article is focused on using bcachefs as the root file system on Gentoo and is intended to be followed alongside the Handbook.
Disk setup
Grub does not currently have a bcachefs driver, although a bug is opened, so having a unified /boot is required (or a /boot on a different partition)
The disk layout for bcachefs is similar to a normal disk layout using ext4 or XFS: a vfat boot partition, a swap partition, and the bcachefs partition.
root #
mkfs.vfat -F 32 /dev/sda1
root #
mkswap /dev/sda2
root #
mkfs.bcachefs /dev/sda3
Or, using bcachefs's cli tools:
root #
bcachefs format /dev/sda3
Before proceeding, follow the handbook and resume this guide after reaching Applying a filesystem to a partition.
Subvolumes
Subvolumes in bcachefs are similar to those in btrfs, but with one benefit: they don't need to be mounted! When the root file system is mounted, the subvolumes are mounted along with it.
To create a subvolume for /home, run the following:
root /mnt/gentoo #
bcachefs subvolume create home
Listing subvolumes is still a work in progress so for now, verifying the subvolumes exist will not be possible.
Continue following the Handbook and return upon reaching Configuring the Linux kernel
Kernel Config
For configuring the kernel, following the manual configuration guide in the Handbook should be sufficient, all that needs to be changed for bcachefs is:
File Systems --->
<*> bcachefs filesystem support (EXPERIMENTAL)
[ ] bcachefs quota support
[ ] bcachefs erasure coding (RAID5/6) support (EXPERIMENTAL)
[*] bcachefs POSIX ACL support
[ ] bcachefs runtime info
[ ] bcachefs debugging
[ ] bcachefs unit and performance tests
[ ] bcachefs lock time statistics
[ ] disable latency accounting and time stats
If a lscpu shows ssse3 and/or avx2 it is recommended to enable also:
-*- Cryptographic API --->
Accelerated Cryptographic Algorithms for CPU (x86) --->
[*] Ciphers: ChaCha20, XChaCha20, XChaCha12 (SSSE3/AVX2/AVX-512VL)
[*] Hash functions: Poly1305 (SSE2/AVX2)
[*] Hash functions: SHA-224 and SHA-256 (SSSE3/AVX/AVX2/SHA-NI)
[*] CRC32c (SSE4.2/PCLMULQDQ)
After building the Kernel, if the Distribution Kernel config was used, install the initramfs with
Using sys-kernel/gentoo-sources should automatically run dracut after make install if sys-kernel/installkernel is built with the dracut USE flag, but in case it does not, this instruction should help.
root #
dracut --kver=6.12.16-gentoo
/etc/fstab
An example fstab for a bcachefs rootfs looks like:
/etc/fstab
/dev/sda1 /boot vfat defaults 1 2
/dev/sda2 none swap sw 0 0
/dev/sda3 / bcachefs defaults 0 0
Dracut will fail to boot if the option
fs_passno
in the fstab (the second number in 0 0 columns) is set to >0 due to it thinking the file system is ext4, set it to 0 in the meantime. (There is a dracut hook but this guide has not tested it yet.)and finally finish the Handbook, resuming at configuring the system.
Userspace Tools
Installing these tools for bcachefs on root are required!
To manage bcachefs in userspace, the package sys-fs/bcachefs-tools will need to be installed.
root #
emerge --ask sys-fs/bcachefs-tools
Issues
Multi Device Root FS
Using the command to add a second partition to one bcachefs pool currently leaves the system unbootable when used on the rootfs, so should not be used until bcachefs support is added to sys-boot/grub and other bootloaders. This will work fine if you have the rootfs on one pool and create a second pool which uses multiple partitions.
To tracker this bug please follow this bug report.
This could be worked around by creating your own custom initramfs however this will need a lot of management on the user's part over the lifetime of the system.