Bcachefs on Fedora: Experience a File System “Fast as XFS, Feature-rich as ZFS”

Fedora tutorial - IT technology blog
Fedora tutorial - IT technology blog

Bcachefs – A Worthy Successor to Btrfs and ZFS?

Fedora chose Btrfs as the default for a reason, but for those who love “tinkering” and need practical speed, Bcachefs is the real deal. I’ve used Fedora as my primary dev machine for over 2 years. While satisfied with the fresh packages, I’ve always searched for something that makes source code and databases run smoother.

Since Linux kernel 6.7, Bcachefs has officially joined the ranks. It combines XFS speed, Btrfs’s Copy-on-Write (CoW) features, and ZFS-style flexible drive management. The biggest plus? It’s incredibly easy to configure. In this article, I’ll guide you through experiencing Bcachefs on Fedora right now without needing to be a kernel expert.

Quick Start: Installation and Drive Creation in 5 Minutes

Important note: Back up your data first. Although Bcachefs is in the mainline kernel, it is still under active development. You can never be too careful.

Step 1: Install Management Tools

The Fedora kernel already supports it; you just need the toolset for formatting and administration.

sudo dnf install bcachefs-tools

Step 2: Format a Single Drive

Suppose you have an empty SSD at /dev/sdb. The following command will format it:

sudo bcachefs format /dev/sdb

Step 3: Mount and Use

sudo mkdir /mnt/bcachefs
sudo mount -t bcachefs /dev/sdb /mnt/bcachefs

That’s it! You have a Bcachefs partition ready to go. But the real power lies in the next section.

Why is Bcachefs Buzzing More Than Btrfs?

Many ask: “Btrfs is running fine, why switch?”. Through real-world experience, Bcachefs handles Btrfs’s inherent weaknesses well:

  • Write Performance: Bcachefs excels at handling small files and databases. In IOPS tests, it often provides more stable results than Btrfs when the disk is over 80% full.
  • Native Encryption: Built-in encryption without the need for an intermediate LUKS layer helps reduce latency.
  • True Tiering: This is the “ultimate weapon.” You can automatically turn an SSD into a cache for an HDD.

Advanced Configuration: Drive Pooling and Tiering

Imagine you have a 256GB NVMe drive (/dev/nvme0n1) and a 2TB HDD (/dev/sda). We will pool them into a single partition while maintaining SSD speeds.

Create a Multi-drive File System

sudo bcachefs format \
    --label=ssd.ssd1 /dev/nvme0n1 \
    --label=hdd.hdd1 /dev/sda \
    --foreground_target=ssd1 \
    --promote_target=ssd1 \
    --background_target=hdd1

How it works:

  • --foreground_target=ssd1: New data is prioritized for writing to the SSD for immediate speed.
  • --promote_target=ssd1: Frequently accessed files are automatically promoted to the SSD.
  • --background_target=hdd1: When the system is idle, old or rarely used data is moved to the HDD to make room on the SSD.

Mount a Multi-drive System

Just list the drives separated by colons:

sudo mount -t bcachefs /dev/nvme0n1:/dev/sda /mnt/storage

Security with Native Encryption

Instead of complex LUKS configurations, Bcachefs allows encryption during formatting. This encryption performance is excellent thanks to CPU AES-NI instruction sets.

sudo bcachefs format --encrypted /dev/sdc

The system will ask for a password at this point. When mounting, you only need to enter the password once—no need for multiple layers of virtual device management.

Real-world Tips

After “torturing” Bcachefs on Fedora for a while, I’ve gathered a few tips:

1. Check Capacity Accurately

The df -h command often reports incorrect capacity for CoW file systems. Use the specialized command:

bcachefs fs usage /mnt/bcachefs

2. Save Space with Zstd

By default, Bcachefs doesn’t compress data. If you store source code (lots of text files), enable Zstd to save up to 40% of space:

sudo bcachefs setattr --compression=zstd /mnt/bcachefs

3. Configure Auto-mount (fstab)

To have the system recognize the drive on boot, add the following line to /etc/fstab:

/dev/nvme0n1:/dev/sda  /mnt/storage  bcachefs  defaults,nofail  0  0

The nofail option is crucial. It ensures the system still boots if one drive in the pool happens to fail.

Conclusion

Bcachefs is a major leap forward for Linux storage. While Fedora still prioritizes Btrfs for safety, Bcachefs is an excellent choice if you prioritize performance and tiering features. If you’re running Fedora Server for a home lab, try pooling an old SSD with an HDD—the speed will surprise you!

Share: