Ramblings of an aging IT geek
← Ramblings of an aging IT geek
linux

moving root onto zfs and not regretting it

A short note on rebuilding a Linux box with ZFS on root, mostly for the boot environments and snapshots before upgrades.

A Linux terminal showing a login prompt

I rebuilt my main server with ZFS on root this week, and the reason is entirely boring: I want to be able to undo a bad upgrade in one command. Boot environments give you that. Snapshot the root dataset before you touch anything, and if the update goes sideways you roll back to the snapshot and reboot. No rescue USB, no reinstall, no quiet panic.

The install itself is more fiddly than ext4 on a partition, because you're hand-rolling the pool layout and the dataset hierarchy before the OS is even there. Separate datasets for the bits you don't want in the root snapshot matter:

zfs create -o canmount=off rpool/ROOT
zfs create -o mountpoint=/ rpool/ROOT/default
zfs create -o mountpoint=/var/log rpool/var-log
zfs create -o mountpoint=/home rpool/home

Splitting /var/log and /home out keeps them off the root environment, so rolling back the OS doesn't eat your logs or your files. That's the bit I'd have got wrong the first time if I hadn't read someone else getting it wrong first.

A week in, I've already used it once. An upgrade left the box not booting cleanly, I rolled back the root dataset, rebooted, and was back where I started in under two minutes. That alone paid for the extra setup time. The snapshots cost almost nothing until something actually changes, and the peace of mind before an upgrade is worth more than the disk space. I should have done this years ago.