Create the filesystems
Two filesystems: FAT32 on the boot partition, because that is what both firmwares can read, and btrfs on everything else.
: "${ESP:?set ESP first}" "${ROOTDEV:?set ROOTDEV on the previous page}" &&
mkfs.fat -F32 -n ESP "$ESP" &&
mkfs.btrfs -L arch "$ROOTDEV"
-n and -L set filesystem labels, which are a convenience rather
than a requirement – they make lsblk readable and give you a
fallback way to identify a disk whose UUID you do not have in front
of you.
mkfs.btrfs writes to whatever $ROOTDEV points at, and the guard
on the first line only stops it being empty. If you set up LUKS on
the previous page it must be /dev/mapper/cryptroot; if you skipped
it, the bare partition. Running echo "$ROOTDEV" costs nothing and
formatting the wrong device costs an afternoon.
Create the subvolumes
Mount the new filesystem at its top level for a moment, create the subvolumes, and unmount it again. Nothing lives at the top level afterwards – it exists only as a container for the subvolumes:
mount "$ROOTDEV" /mnt btrfs subvolume create /mnt/@ btrfs subvolume create /mnt/@home btrfs subvolume create /mnt/@snapshots btrfs subvolume create /mnt/@log btrfs subvolume create /mnt/@pkg btrfs subvolume create /mnt/@swap umount /mnt
The leading @ is a naming convention, not a requirement. It makes
subvolumes obvious at a glance and is what most Arch and Debian
tooling expects to find.
| Subvolume | Mounted at | Why it is separate |
|---|---|---|
@ |
/ |
The system itself – the thing you roll back |
@home |
/home |
Your data, which must survive a rollback of the system |
@snapshots |
/.snapshots |
Where snapshots are kept; cannot live inside @ |
@log |
/var/log |
Logs of what went wrong should outlive the rollback |
@pkg |
/var/cache/pacman/pkg |
A re-downloadable cache, not worth snapshotting |
@swap |
/swap |
A swapfile cannot sit on a subvolume that gets snapshotted |
The reasoning behind all six is the same: anything you would want to
keep when rolling the system back, and anything you would never want
to copy into a snapshot, has to be outside @. Deciding this now
costs one command each; deciding it later means moving data around on
a running system.
This chapter only creates the subvolumes. Taking actual snapshots needs a tool to manage them, which is a later chapter – but the layout has to be right from the start, so it is done here.