Btrfs is a copy-on-write filesystem built into the Linux kernel. It brings features that ext4 lacks: instant snapshots, subvolumes, transparent compression, checksums on data and metadata, and incremental send/receive replication. It’s the default on openSUSE and Fedora desktops, and a practical choice for backup disks and servers where snapshots are handy.
Create a Btrfs filesystem
sudo apt install btrfs-progs
sudo mkfs.btrfs -L data /dev/vdb1
sudo mkdir -p /mnt/data
sudo mount -o compress=zstd:3,noatime /dev/vdb1 /mnt/data
In /etc/fstab:
UUID=… /mnt/data btrfs defaults,compress=zstd:3,noatime,nofail 0 0
Subvolumes
A subvolume is an independently snapshottable directory tree inside the filesystem. All subvolumes share the free space, with no partition sizing.
sudo btrfs subvolume create /mnt/data/www
sudo btrfs subvolume create /mnt/data/db
sudo btrfs subvolume list /mnt/data
A subvolume can be mounted directly:
UUID=… /var/www btrfs subvol=www,compress=zstd:3,noatime 0 0
Splitting data into subvolumes lets you snapshot and roll back each part separately, for example the website without the database.
Snapshots
A snapshot is a subvolume that starts as an exact copy, created instantly and sharing all unchanged data:
sudo mkdir -p /mnt/data/.snapshots
sudo btrfs subvolume snapshot -r /mnt/data/www /mnt/data/.snapshots/www-$(date +%F-%H%M)
-r makes it read-only. That’s best for backups, and required for send.
Restore a file by copying it from the snapshot directory:
cp -a /mnt/data/.snapshots/www-2026-10-14-0300/site/config.php /mnt/data/www/site/
Roll back an entire subvolume (unmount it first if it’s mounted separately):
sudo mv /mnt/data/www /mnt/data/www.broken
sudo btrfs subvolume snapshot /mnt/data/.snapshots/www-2026-10-14-0300 /mnt/data/www
sudo btrfs subvolume delete /mnt/data/www.broken
Delete old snapshots:
sudo btrfs subvolume delete /mnt/data/.snapshots/www-2026-09-*
Automate this with snapper or btrbk (scheduled snapshots with retention policies). Snapshots live on the same disk, so they protect against mistakes, not disk failure.
Send/receive: incremental backups
Replicate snapshots to another Btrfs disk or server:
# first full copy
sudo btrfs send /mnt/data/.snapshots/www-day1 | ssh backup sudo btrfs receive /backup/www
# then only the differences
sudo btrfs send -p /mnt/data/.snapshots/www-day1 /mnt/data/.snapshots/www-day2 |
ssh backup sudo btrfs receive /backup/www
btrbk automates this flow. See the 3-2-1 backup rule.
Compression
compress=zstd:3 compresses new writes transparently. Text, logs, databases and code often shrink 2–3×. Compress existing data:
sudo btrfs filesystem defragment -r -czstd /mnt/data/www
Measure it with compsize (sudo apt install btrfs-compsize):
sudo compsize /mnt/data
Real disk usage
df can be misleading on Btrfs, because of shared snapshot data and metadata allocation. Use:
sudo btrfs filesystem usage /mnt/data
sudo btrfs filesystem du -s /mnt/data/*
Old snapshots hold on to deleted data. If space doesn’t come back after deleting files, delete old snapshots too.
Scrub and health
sudo btrfs scrub start /mnt/data
sudo btrfs scrub status /mnt/data
sudo btrfs device stats /mnt/data # read/write/checksum error counters
On a single disk, a scrub detects corruption. With RAID1 profiles across two disks, it also repairs it.
Multi-disk and RAID profiles
sudo mkfs.btrfs -d raid1 -m raid1 /dev/sdb /dev/sdc
sudo btrfs device add /dev/sdd /mnt/data && sudo btrfs balance start /mnt/data
RAID1 and RAID10 profiles are stable. RAID5/6 is still not recommended for important data. Use mdadm or ZFS for parity RAID. See ZFS on Linux.
Databases and VM images on Btrfs
Copy-on-write fragments files that are constantly rewritten in place, like database files and VM disk images. Disable CoW for those directories before creating the files:
sudo mkdir /mnt/data/db/mysql
sudo chattr +C /mnt/data/db/mysql
That also disables checksums and compression for those files. Many admins simply keep busy databases on ext4 or XFS.
Btrfs vs ZFS vs ext4 + LVM
| Need | Choose |
|---|---|
| Simple, proven, general use | ext4 (+ LVM) |
| Snapshots in-kernel, no extra modules | Btrfs |
| Parity RAID with integrity, big storage | ZFS |
| Busy databases | ext4 or XFS |
Quick reference
| Task | Command |
|---|---|
| Create subvolume | btrfs subvolume create /mnt/data/x |
| Read-only snapshot | btrfs subvolume snapshot -r src dst |
| List | btrfs subvolume list /mnt/data |
| Delete | btrfs subvolume delete path |
| Usage | btrfs filesystem usage /mnt/data |
| Scrub | btrfs scrub start /mnt/data |
| Send incremental | btrfs send -p old new | btrfs receive dir |
Related: LVM snapshots and database backup automation.