Btrfs (B-tree File System) is a modern Linux file system built on copy-on-write (CoW) principles that combines volume management and file system layers into a single storage architecture. By managing multiple physical drives directly as one unified storage pool, it eliminates the need for separate layers like LVM or MDADM while enabling live expansion, built-in RAID, and instant snapshots.
How it works
Traditional file systems overwrite existing data blocks in place, which risks partial writes and corruption during sudden power loss. Btrfs instead uses copy-on-write: whenever data or metadata changes, the modified blocks are written to newly allocated free space before the file system pointers are updated atomically. Because the previous blocks remain untouched until the transaction commits, Btrfs avoids the classic RAID write hole and creates near-instantaneous, space-efficient snapshots simply by referencing existing B-tree nodes.
Data integrity is enforced through mandatory checksums (such as CRC32C or xxhash) stored separately from the data blocks themselves. During read operations or scheduled scrubs, Btrfs verifies these checksums and, when paired with redundant profiles like RAID1 or RAID10, automatically repairs silent bit rot using a healthy copy. Other core capabilities include subvolumes that act as independently mountable POSIX file trees, dynamic inode allocation, and transparent inline compression using zstd, zlib, or lzo.
Example
In a typical server setup, an administrator might add a second NVMe drive to an existing Btrfs mount point, convert the pool to RAID1 for redundancy, and capture a read-only snapshot before running system updates:
# Add a new block device to a live mount and rebalance into RAID1
btrfs device add /dev/nvme1n1 /srv/data
btrfs balance start -dconvert=raid1 -mconvert=raid1 /srv/data
# Create a read-only snapshot of an application subvolume
btrfs subvolume snapshot -r /srv/data/app /srv/data/snapshots/app-pre-upgrade
What matters when choosing a server or hosting
- Drive count and redundancy: Btrfs RAID1 mirrors data across at least two drives regardless of mismatched capacities, making it practical for dedicated servers with mixed disks. Avoid Btrfs RAID5 and RAID6 for critical production workloads due to longstanding parity stability concerns.
- Storage media and IOPS: Copy-on-write increases random write amplification, especially on busy databases or virtual machine images. Enterprise NVMe or SSD storage with power-loss protection handles this overhead far better than spinning hard drives.
- Kernel and tool versions: Btrfs remains under active kernel development, so choosing a hosting OS image with a recent long-term support Linux kernel ensures access to mature stability fixes and modern checksum algorithms.
Common mistakes
- Running databases on CoW subvolumes without tuning: Heavy random-write workloads like PostgreSQL or MySQL suffer severe fragmentation under CoW. Place database directories on dedicated subvolumes mounted with
nodatacowor rely on application-level replication rather than file system snapshots. - Ignoring free space monitoring: Because Btrfs separates metadata and data chunk allocations, a volume can run out of metadata space even when
dfreports available gigabytes. Monitor actual chunk allocation withbtrfs filesystem usageinstead of standard utilities alone. - Skipping periodic scrubs: Checksums only detect silent corruption when blocks are read. Failing to schedule regular
btrfs scrubjobs leaves cold data unverified until a failure occurs.
FAQ
Is Btrfs ready for production servers?
Yes, for single-drive setups, JBOD pools, and RAID1 or RAID10 configurations on recent kernels. Many Linux distributions and enterprise storage platforms use it as their default root file system, provided administrators avoid RAID5/6.
How does Btrfs differ from ZFS?
Btrfs is merged directly into the mainline Linux kernel under the GPL license and allows flexible, mixed-size drive additions in RAID1. ZFS relies on an out-of-tree CDDL kernel module, offers mature RAID-Z parity, and generally demands higher baseline RAM for caching.
Can I disable copy-on-write for specific files?
Yes. You can set the +C attribute using chattr +C on an empty directory or new file, or mount a dedicated subvolume with the nodatacow option to prevent fragmentation on virtual machine disk images and databases.