Skip to Content
MvpDots

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.

SubvolumeMounted atWhy it is separate
@/The system. This is what snapshots capture.
@home/homeYour files survive a system rollback.
@cache/var/cachePackage downloads: big, and worthless in a snapshot.
@log/var/logLogs must survive a rollback, so you can see what went wrong.
@snapshots/.snapshotsWhere snapper keeps the snapshots (folder mode 750).
@swap/swapA swapfile cannot live in a subvolume that gets snapshotted.

Mount options

noatime,compress=zstd:1,ssd,discard=async,space_cache=v2
  • noatime: 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/swapfile

mkswapfile 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>):

/etc/fstab
 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 0

Check it

Terminal
findmnt -t btrfs -o TARGET,OPTIONS | cut -c1-90
swapon --show
sudo compsize /        # how much compression saves

Result: on a fresh install, 6.9 GB of files took 4.1 GB on disk.

On this page