DateisystemeSite

Btrfs, like ZFS, is a hybrid system of file system and volume manager. It breaks up the rigid 1:1 assignment of partition and file system.

In contrast to ZFS, which has strict rules for VDEVs, Btrfs focuses on maximum flexibility. You can throw drives of different sizes into a pool, change RAID levels on the fly (convert), and dynamically add or remove capacity.

The goal is a “self-healing” system that is firmly integrated into the Linux kernel (GPL license), which ZFS is denied due to license conflicts.

Core Mechanics: The “Why” Behind the Technology

Everything is a B-tree

The name says it all. Almost every structure in Btrfs is a B-tree. This ensures efficient lookups and scalability.

The most important aspect, however, is Copy-on-Write (CoW):

  • Data is never overwritten.
  • Changed blocks are written to new positions.
  • Only when the data is safe is the B-tree pointer updated.

Architectural consequence:

The file system is consistent during power outages. An fsck theoretically takes only seconds, as the tree only needs to be traced back to the last valid transaction.

Subvolumes (the “Directory Partitions”)

In ext4 or XFS, a partition is a rigid boundary. In Btrfs, you create subvolumes.

A subvolume behaves like a directory, but can be mounted separately and has its own snapshot policies.

  • Advantage: You install Linux. /, /home and /var are subvolumes. They share the same free space in the pool. You don’t have to guess beforehand how big /var it has to be.

Snapshots & Rollback

Since Btrfs is based on CoW, a snapshot doesn’t cost any space (it just freezes the state of the B-tree pointers).

Tools like Snapper (standard with OpenSUSE) use this:

  1. Before each yum update or apt upgrade a snapshot is automatically created.
  2. If the update goes wrong, simply boot into the snapshot from “5 minutes ago”.
  3. The file system is rolled back to its old state (rollback). This is the main reason why Btrfs is used on workstations and server OS partitions.

Storage Pooling & RAID (Light and Shadow)

This is where Btrfs differs massively from ZFS and traditional RAID.

Chunk-Based RAID

Btrfs does not mirror entire hard drives, but data chunks (usually 1 GB in size).

  • RAID 1 (Mirroring): Btrfs guarantees that two copies of each chunk are on two different devices .
  • Implication: You can insert a 10 TB disk and a 2 TB disk into a RAID 1. You get 2TB of mirrored storage. The rest of the 10 TB disk remains usable (as a single or for other RAIDs). No other enterprise FS offers this flexibility.

“RAID 5/6 Warning” (The Write-Hole)

As a system architect, I have to issue a clear warning here:

Never use Btrfs RAID 5 or RAID 6 for productive data (as of today).

Btrfs has an unresolved “write hole” issue with parity RAID. If the power fails during a write operation, data and parity may no longer match. Since Btrfs doesn’t use a journal for parity (as mdadm it could), this will result in corrupt data on a rebuild.

  • Solution: For RAID 5/6, use the underlying mdadm or hardware RAID and simply format the resulting device as “Single” Btrfs (this is how Synology does it, for example).

Features & Tuning

Transparent compression

You can mount directories or subvolumes with .compress=zstd

  • Causality: Modern CPUs (ZSTD) compress faster than the SSD can write. So you gain storage space and write speed (throughput), because less physical data has to go to the flash memory.

Deduplication (Out-of-Band)

Unlike ZFS (In-Band / Realtime), Btrfs usually relies on out-of-band deduplication (e.g. with tools such as duperemove or bees).

  • The system scans for duplicate blocks in the background and merges them.
  • Advantage: It doesn’t load the write path. The RAM requirement is moderate.

Rebalance

Since Btrfs distributes data chunk-based, a pool can become “unbalanced” when you add disks.

The btrfs balance command rewrites the data over all available discs. This is essential after an expansion, but takes a very long time with large amounts of data and generates high I/O load.

Conclusion & Recommended Use

Btrfs is the “Swiss Army Knife”. It is not quite as robust as the “tank” ZFS, but much more flexible and more deeply integrated into the Linux ecosystem.

ScenarioRecommendationJustification
Linux Root PartitionIdealSnapshots allow for safe patching/updating.
Mixed-Drive NASGood (RAID1)Perfect if you want to recycle old hard drives of different sizes.
Enterprise StorageConditionalOver mdadm or Hardware RAID only. Avoid native Btrfs RAID logic.
Container / DockerVery GoodThe Btrfs storage driver for Docker is extremely efficient for layer management.

Tip: If you’re using a Synology NAS, you’ll see “Btrfs” there. However, Synology wisely uses mdadm (Linux Software RAID) for redundancy (RAID 5/6) and only puts Btrfs on top of it as a logical layer (for bit-rot detection and snapshots). This is a valid, stable architecture.

This post is also available in: Deutsch English