btrfs where it fits - snapshots, subvolumes, and operations
What you'll learn
- Identify when btrfs is the right choice over ext4/xfs
- Create and use btrfs snapshots and subvolumes
- Use btrfs send/receive for incremental backup
- Run btrfs scrub and balance
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
btrfs is a modern copy-on-write filesystem with features that make it ideal for specific workloads. Choosing btrfs is a deliberate choice based on the workload and the team’s operational readiness.
When to use btrfs
Use btrfs when you need:
- Snapshots for atomic rollback (after a deployment or a database migration).
- Subvolumes for separate logical filesystems sharing a storage pool.
- Send/receive for incremental backup or replication to another host.
- Built-in compression (zstd, lzo) for space-efficient storage of compressible data.
Do not use btrfs for:
- Production databases that need proven, mature storage (use ext4 or xfs).
- Boot disks on legacy hardware (btrfs boot support has improved but is still tricky).
- Workloads where the operations team has no btrfs experience.
Creating a btrfs filesystem
$ mkfs.btrfs -L data /dev/sda1btrfs-progs v6.6
See http://btrfs.wiki.kernel.org for more information.
Label: data
UUID: abc12345-...Subvolumes
$ btrfs subvolume create /data/projectsCreate subvolume '/data/projects'Snapshots
$ btrfs subvolume snapshot -r /data/projects /data/projects-snap-2026-01-01Create a readonly snapshot of '/data/projects' in '/data/projects-snap-2026-01-01'Send/receive for backup
$ btrfs send /data/projects-snap | btrfs receive /backup/projectsAt subvol /data/projects-snap
At subvol /backup/projectsA bare btrfs send sends the whole snapshot. To send only what
changed, keep the previous read-only snapshot on both sides
and name it as the parent:
$ btrfs send -p /data/projects-snap-2026-01-01 /data/projects-snap-2026-01-02 | btrfs receive /backup/projectsAt subvol /data/projects-snap-2026-01-02
At snapshot /data/projects-snap-2026-01-02Scrub and balance
$ btrfs scrub start /datascrub: started on /data, generation 42$ btrfs balance start /dataDone, had to relocate 5 out of 12345 chunksKnowledge check
Knowledge check · 5 questions
Q1. What is the primary advantage of btrfs over ext4 for production deployment workloads?
Q2. btrfs snapshots are instant and do not copy data at creation time.
Q3. Which of the following are correct uses of btrfs? Select all that apply.
Q4. A nightly cron takes a snapshot and pipes it to btrfs send over SSH. It has reported nothing for six weeks and the destination has no new subvolumes. The snapshot command is btrfs subvolume snapshot /data/projects /data/snap-$(date +%F). What is the fault?
Q5. An incremental btrfs send needs the parent snapshot to still exist on the source and the destination, so the two sides must be pruned together.
Passing score: 75%. Answers are checked in this browser.