Tutorial 07 · FreeBSD

Boot environments with bectl

Snapshot your whole system before risky changes and boot back into it if something breaks.

Last updated

A boot environment (BE) is a bootable clone of the root filesystem. On a ZFS install, BEs make upgrades almost risk free: if a change goes wrong, you pick the previous BE from the loader menu and you're back.

1List boot environments

bectl list

The Active column shows N for the BE running now and R for the one that boots on the next reboot.

2Create one before a change

bectl create before-upgrade
bectl list

The new BE is a cheap ZFS clone of the current one. Continue with your upgrade as normal; if all is well, you simply keep running the default BE.

3Roll back

From the running system, activate the old BE and reboot. Or, at the loader menu, choose Boot Environments and select it.

bectl activate before-upgrade
shutdown -r now

# activate for the next boot only:
bectl activate -t before-upgrade

4Inspect or change a BE without booting it

bectl mount before-upgrade /mnt
ls /mnt/etc
bectl umount before-upgrade

You can also upgrade a mounted BE in place with tools that accept a target root, then activate it, leaving the running system untouched until reboot.

5Clean up

bectl destroy -o before-upgrade    # -o also destroys its origin snapshot
bectl rename default stable

← All FreeBSD tutorials