What Btrfs Is
A filesystem is the system that decides how files live on a disk: where the bytes sit, what each file is called, and how to find them again. Btrfs (pronounced "butter-eff-ess", short for B-tree filesystem) is a filesystem for Linux with a particular set of talents: it can freeze the state of your files at a moment in time (a snapshot), it checksums everything it stores so silent corruption gets caught, it can spread data across several disks, and it can send the difference between two snapshots to another machine as a backup.
The talent everything else hangs on is copy-on-write, usually shortened to CoW. When you change a file on a traditional filesystem, the new bytes are written over the old ones: the old version is gone. On Btrfs the new bytes are written to a fresh, empty place, and only when they are safely down does the filesystem point the file at them. The old bytes stay where they were until nothing refers to them any more. That one design decision buys almost everything in this guide: a snapshot is just the filesystem keeping hold of the old pointers, which is why a snapshot of a whole system takes a second and, at first, no extra space.
The rule, stated before everything else
Btrfs makes snapshots so cheap and so easy that they feel like backups. They are not, and this guide has one rule, stated here and repeated wherever it matters:
A snapshot is not a backup. A snapshot lives on the same disk as the original, and copies on the same disk die with the disk.
A snapshot protects you against yourself: the file you deleted, the update that broke the system, the edit you wish you had not saved. It protects you against nothing that happens to the disk itself — failure, fire, theft, a formatting command typed at the wrong device. For that you need the data somewhere else: another disk, another machine, another building. Chapter 7 shows Btrfs's own tool for that journey, send and receive, which turns snapshots into backups that travel. Until a copy has travelled, it is not a backup, however many snapshots you have.
Why anyone would choose it
- Snapshots and rollback. Take a snapshot before a system upgrade. If the upgrade goes wrong, roll back to the snapshot and the machine is as it was. Whole distributions are built around this trick.
- Checksums that catch rot. Every block of data and metadata carries a checksum — a small fingerprint computed from the bytes. When the bytes change and the fingerprint no longer matches, Btrfs says so, instead of silently handing you damaged data. On a mirrored setup it can often repair the damage from the good copy.
- Several disks, one filesystem. Btrfs can stripe or mirror data across disks itself (chapter 8), with no separate RAID layer underneath.
- Backups that send only the changes. Send and receive ships the difference between two snapshots, so a daily backup moves minutes of data, not the whole disk (chapter 7).
- Subvolumes. Inside one filesystem you can carve out subvolumes — separate file trees that share the same pool of space and can be snapshotted independently, like folders with superpowers (chapter 5).
What it costs
Copy-on-write is not free. A file that is constantly rewritten in place — a database, a virtual machine image — gets scattered into pieces (fragmentation), and some workloads need the copy-on-write behaviour turned off for particular files. Btrfs is also younger and stranger than the traditional ext4: its tools report space in ways that confuse everyone the first time, and some of its corners (quotas, chapter 10; RAID5 and RAID6, chapter 8) carry honest warnings. Chapter 14 collects the limits in one place.
Who it is for
The Linux user who wants a safety net before upgrades. The home archivist who wants to know if a photo has rotted, rather than hope it hasn't. The small-server keeper who wants several disks to behave as one pool with mirroring, without learning a separate volume manager first. If any of that is you, the next chapter takes the machine apart, piece by piece, before chapter 4 builds one.