Skip to content

ZFS Boot Environments

Operating systems can break during major updates. Maybe the developers did something wrong. Maybe you hacked a bit too much on the OS prior to upgrading. Whatever the case, the result is downtime, which is usually a bad thing.

FreeBSD Boot Environments

FreeBSD has a great tool called bectl(8), which allows you to create bootable ZFS snapshots. When you create one, you'll be able to boot to the system as it is when you run that command.

Even cooler is FreeBSD automatically creates a boot environment for you when you run freebsd-update(8) to update the system.

Here's an example of the boot loader options that allow you to select a boot environment. When you see the loader screen, you can press spacebar to give yourself some time to read the options. Option 8 is "Boot Environments." So press 8.

FreeBSD Loader Main Menu
The first menu presented by the FreeBSD loader. Item 8 takes you to boot environments.

Next you get this simple menu. Press 2 repeatedly to cycle through the boot environments you have available. (If you just installed and have never updated FreeBSD and also never manually created a boot enviroment, you might not have any options.) Or press 3 to go back to the default boot.

FreeBSD Loader Boot Environments Menu
The Boot Environments menu presented by the FreeBSD loader. Item 2 will cycle through boot environments. Item 3 goes to default.

Linux GRUB Options

Most Linux distributions like Debian offer minimal ability to roll back by default. They usually keep at least one old copy of the kernel in case it doesn't boot, but the kernel is just one part of the system. So if some critical application broke during an upgrade, using an old kernel might not be enough to quickly get it back up and running.

Here's a Debian boot showing the current and previous kernels on the GRUB Advanced Boot Menu.

Debian GRUB Kernel Options
The advanced GRUB boot menu on Debian 12. From here, a user can select an older kernel version.

A Better Safety Net

Boot Environments make major upgrades a lot less stressful. If catastrophe strikes, you can boot to the previous state until you can figure out what went wrong.