Disk layout
One Linux partition, formatted as Btrfs, split into subvolumes. A subvolume behaves like its own filesystem (it can be snapshotted on its own), but every subvolume shares the free space of the partition.
| Subvolume | Mounted at | Why it is separate |
|---|---|---|
@ | / | The system. This is what snapshots capture. |
@home | /home | Your files survive a system rollback. |
@cache | /var/cache | Package downloads: big, and worthless in a snapshot. |
@log | /var/log | Logs must survive a rollback, so you can see what went wrong. |
@snapshots | /.snapshots | Where snapper keeps the snapshots (folder mode 750). |
@swap | /swap | A swapfile cannot live in a subvolume that gets snapshotted. |
Mount options
noatime,compress=zstd:1,ssd,discard=async,space_cache=v2noatime: don't write a timestamp every time a file is read.compress=zstd:1: transparent compression at the fastest level. On a fresh install, 6.9 GB of files took 4.1 GB on disk.discard=async: tell the SSD about freed blocks in the background (TRIM).space_cache=v2: the modern free-space cache.
The swap subvolume leaves out compress: swapfiles must not be compressed.
Swapfile
sudo btrfs filesystem mkswapfile --size 16g /swap/swapfile
sudo swapon /swap/swapfilemkswapfile creates the file with copy-on-write and compression already off. Full example: files/fstab.example in the playbook.
Never format, resize or relabel a partition you share with another system. Every step here only touches the Linux partition.
Before and after
What changed in /etc/fstab compared with a single-subvolume install (disk IDs replaced with <uuid>):
UUID=<uuid> / btrfs subvol=/@,noatime,compress=zstd:1,ssd,discard=async,space_cache=v2 0 0
UUID=<uuid> /home btrfs subvol=/@home,noatime,compress=zstd:1,ssd,discard=async,space_cache=v2 0 0
+UUID=<uuid> /var/cache btrfs subvol=/@cache,noatime,compress=zstd:1,ssd,discard=async,space_cache=v2 0 0
+UUID=<uuid> /var/log btrfs subvol=/@log,noatime,compress=zstd:1,ssd,discard=async,space_cache=v2 0 0
+UUID=<uuid> /.snapshots btrfs subvol=/@snapshots,noatime,compress=zstd:1,ssd,discard=async,space_cache=v2 0 0
+UUID=<uuid> /swap btrfs subvol=/@swap,noatime,ssd,discard=async,space_cache=v2 0 0
+/swap/swapfile none swap defaults 0 0Check it
findmnt -t btrfs -o TARGET,OPTIONS | cut -c1-90
swapon --show
sudo compsize / # how much compression savesResult: on a fresh install, 6.9 GB of files took 4.1 GB on disk.