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

moving root onto zfs, and why i'd do it again

A quick note on moving a Linux root filesystem onto ZFS on Linux, and the boot-environment snapshot habit that made it worth the fiddle.

A Linux terminal full of text

I finally moved this machine's root filesystem onto ZFS. Not a data pool bolted on the side, the actual root, the thing that boots. I'd put it off for ages because root-on-ZFS on Linux has a reputation for fiddliness, and the reputation is earned. You're juggling the initramfs, a working zpool import at boot, and a bootloader that can find the kernel before the pool is up.

The setup itself isn't the interesting part. ZFS on Linux 0.6.5 is stable enough that the mechanics are well-trodden: create the pool, set mountpoint=/ and the bootfs property, get the zfs and spl modules into the initramfs so it can import on boot. The Ubuntu and Arch wikis both walk it through and I'd just follow whichever matches your distro rather than wing it.

The reason I bothered is one habit: boot environments. Before any risky upgrade I now run a snapshot, do the upgrade, and if it goes wrong I roll back in seconds instead of reinstalling.

zfs snapshot rpool/ROOT/default@pre-upgrade

If the upgrade eats itself, I roll the dataset back to that snapshot and reboot into exactly the system I had ten minutes earlier. No reinstall, no restore from backup, no evening lost. I've already used it once, after a kernel update left the box unbootable, and that single rollback paid for the whole afternoon of fiddling. Worth it.