bcachefs is a copy-on-write filesystem for Linux that combines data checksumming, transparent compression, native encryption, snapshots, replication and multi-device storage tiering in a single kernel filesystem. It grew out of bcache, the block-layer caching driver, and reuses its core idea: a fast, general-purpose key-value store built on B+ trees, with the filesystem implemented as a layer on top of that store.
In the Linux filesystem landscape, bcachefs targets the same feature space as Btrfs and ZFS while aiming for the predictable performance of ext4 and XFS. It was merged into the mainline kernel in Linux 6.7 as an experimental filesystem, later marked as externally maintained, and removed from the mainline tree in Linux 6.18; it is now distributed mainly as an out-of-tree DKMS module together with the userspace package bcachefs-tools.
How bcachefs stores data and metadata
bcachefs stores all metadata in B+ trees keyed by inode number, offset and snapshot ID, rather than in fixed on-disk tables. Separate trees hold extents, inodes, directory entries, extended attributes, allocation information and snapshot records, and a write-ahead journal records recent updates so that tree nodes can be written lazily and in large batches.
Tree nodes are large, typically 256 KiB, and are themselves log-structured: new keys are appended to a node until it is compacted, which keeps random metadata writes cheap. Data space is divided into buckets, the allocation unit inherited from bcache, and a background process called copygc moves live data out of fragmented buckets so they can be reused.
Because every write goes to a new location, bcachefs is copy-on-write: existing data is never overwritten in place, which makes atomic updates, snapshots and checksums natural rather than bolted on. The table below summarizes the main structures.
| Structure | Role | Practical effect |
|---|---|---|
| Extents btree | Maps file offsets to physical locations | Large contiguous extents, low fragmentation |
| Inodes btree | Stores file metadata and options | Per-file compression and replication settings |
| Journal | Records metadata updates before tree writes | Fast commits and crash consistency |
| Buckets | Fixed allocation units on each device | Efficient space reuse via copygc |
| Snapshots btree | Tracks the snapshot tree and IDs | Cheap, scalable snapshots of subvolumes |
Key features and mount options of bcachefs
Most bcachefs features are controlled by options that can be set filesystem-wide, per directory or per file, which is unusual among Linux filesystems. Options are given to bcachefs format, as mount options or later through extended attributes, and child files inherit them from their parent directory.
| Option | Typical values | What it controls |
|---|---|---|
data_checksum | crc32c (default), crc64, xxhash, none | End-to-end integrity of file data |
compression | lz4, gzip, zstd, none | Inline compression of new writes |
background_compression | zstd at a higher level | Recompression when data moves to slow tiers |
data_replicas | 1 to 4 | Number of copies of file data |
metadata_replicas | Often 2 on multi-device sets | Copies of btree metadata |
encrypted | Set at format time | ChaCha20/Poly1305 authenticated encryption |
Native encryption uses ChaCha20 for confidentiality and Poly1305 as a message authentication code, so encrypted data is also authenticated against tampering. Encryption must be chosen when the filesystem is created and is unlocked with bcachefs unlock before mounting.
Erasure coding with Reed-Solomon stripes is implemented but has long been described as experimental, so most production setups rely on plain replication instead.
Multi-device pools and storage tiering
A single bcachefs filesystem can span several block devices of different speeds and sizes, mounted with a colon-separated list such as mount -t bcachefs /dev/nvme0n1:/dev/sda:/dev/sdb /mnt. Devices can be grouped by labels such as ssd and hdd, and target options decide where each kind of I/O lands.
- foreground_target receives new writes, usually the fast SSD group.
- background_target is where data is moved later by the rebalance thread, usually the large HDD group.
- promote_target holds cached copies of frequently read data.
- metadata_target keeps btree nodes on fast media for quick lookups.
Each device also has a durability value: a device with durability 0 acts as a pure cache, while durability 2 can represent a hardware RAID volume. This tiering inside the filesystem replaces the separate LVM cache or bcache layer that would otherwise sit below ext4 or XFS.
How bcachefs compares with other Linux filesystems
bcachefs is most often compared with Btrfs and ZFS, the other copy-on-write filesystems used on Linux, and with the conventional journaling filesystems that most distributions install by default.
| Filesystem | Design | Strengths | Main caveat |
|---|---|---|---|
| bcachefs | Copy-on-write, btree key-value store | Tiering, per-file options, native encryption | Out of mainline, younger code base |
| Btrfs | Copy-on-write, B-tree | Mainline, mature snapshots and send/receive | RAID 5 and 6 still not recommended |
| ZFS | Copy-on-write, pooled storage | Very mature integrity and RAID-Z | Out-of-tree for licensing reasons |
| ext4 | Journaling, in-place updates | Simplicity and wide tooling | No data checksums or snapshots |
| XFS | Journaling, extent-based | Scales to very large files | No native snapshots or compression |
Unlike ZFS, bcachefs is GPL-licensed and was designed for the Linux kernel, so its out-of-tree status is a maintenance and process question, not a licensing one.
Administering bcachefs in practice
Day-to-day administration uses the bcachefs command from bcachefs-tools, which covers formatting, device management, repair and subvolume handling. The decision table below lists common tasks.
| Task | Command | Note |
|---|---|---|
| Create a filesystem | bcachefs format --compression=zstd /dev/sdX | Options can also be set later |
| Add a device | bcachefs device add /mnt /dev/sdY | Works on a mounted filesystem |
| Remove a device | bcachefs device evacuate then device remove | Data is migrated first |
| Create a snapshot | bcachefs subvolume snapshot /mnt/a /mnt/a-snap | Snapshots are subvolumes |
| Check and repair | bcachefs fsck /dev/sdX | Online fsck is also supported |
| Show usage | bcachefs fs usage -h /mnt | Per-device and per-replica breakdown |
Because the module is now distributed outside the kernel tree, administrators must make sure the DKMS module rebuilds for every new kernel and is included in the initramfs if the root filesystem is bcachefs; otherwise the system will not boot after an upgrade.
Limitations and risks of bcachefs
The main risk is maturity and support status, not the design itself. Expert administrators weigh the following points before using bcachefs for important data.
- No mainline kernel support since Linux 6.18, so distribution kernels may not ship the module.
- Fewer years of field use than ext4, XFS, Btrfs or ZFS, and on-disk format versions still evolve.
- Erasure coding remains experimental; replication is the safer redundancy choice.
- Copy-on-write fragmentation can affect databases and virtual machine images with heavy random writes.
- Backups remain mandatory: checksums detect corruption but replicas, not checksums, repair it.
A plain-language summary
bcachefs is a way for a Linux computer to organize files on its drives. It never overwrites old data directly. Instead, it writes changes to a new spot and then switches over, so a power cut does not leave files half-changed.
It also checks every piece of data with a fingerprint called a checksum, can shrink files with compression, can lock them with encryption, and can treat a small fast SSD and a big slow hard drive as one storage pool. New files land on the fast drive first and are moved to the big drive later. The main caveat is that it is still a young filesystem and no longer ships with the standard Linux kernel.
An example from practice
A home lab administrator builds a media and backup server from one 1 TB NVMe SSD and two 8 TB hard drives. Formatting all three as one bcachefs filesystem, the administrator labels the SSD as ssd and the disks as hdd, sets foreground_target and promote_target to ssd, background_target to hdd, and sets data_replicas=2 with zstd background compression.
New uploads are written at SSD speed, then the rebalance thread moves them to both hard drives, compressed. Frequently watched files are promoted back to the SSD cache. When one hard drive later develops bad sectors, checksums flag the damaged extents and bcachefs reads the healthy replica instead, so no files are lost while the failing disk is replaced with bcachefs device add and device remove.