Recipes
Short answers to the jobs that bring most people to btrfs, each one a paragraph and a command or two. Every recipe points back to the chapter that teaches it properly.
Snapshot before every upgrade
sudo btrfs subvolume snapshot -r / /.snapshots/root-$(date +%F)
Read-only, dated, taken before the package manager runs (chapter 6). Roll back by snapshotting the snapshot back into place and rebooting. Delete last month's when this month's has landed.
A backup that leaves the building
Chapter 7's routine in one breath:
snapshot read-only, btrfs send it to a
disk that is not this disk, verify the far
end by restoring a file from the received
copy. Incremental sends (-p with the
previous snapshot as parent) make it a
daily job instead of a weekly event.
Two cheap disks, one honest mirror
For the archive that must survive a dead
disk: two devices, mkfs.btrfs -d raid1
-m raid1 (chapter 8), a monthly scrub
(chapter 9), and backups sent elsewhere
anyway โ RAID1 repairs rot; it does not
survive fire, theft, or the wrong rm.
Tame the virtual machines
Database files and VM images rewritten in place fight copy-on-write (chapter 14). For a directory of them:
chattr +C /mnt/data/vm-images
+C switches copy-on-write off for new
files created there โ at the price of
losing checksums and snapshot-sharing for
those files. Take the trade knowingly, per
directory, not filesystem-wide.
Find what is really using the space
When snapshots pin invisible data
(chapters 6 and 14): enable quotas
temporarily if you must (chapter 10), or
walk the suspects with
btrfs filesystem du -s on each subvolume
and snapshot; the exclusive column is
what deleting each would free.
Practise disaster on a file
The lab's whole method, yours to borrow:
truncate an image, mkfs.btrfs it,
fill it with --rootdir, copy it, break
the copy, and rehearse chapters 9 and 11
against it. Twenty minutes of rehearsal
on a file is cheaper than one first
attempt on the real archive.