I do not have to remind you that I am a big fan of ZFS Boot Environments feature. From the time when I first used it on OpenSolaris and Solaris systems I was really fascinated by it. Bulletproof upgrades and changes to entire system … and it was possible more then decade ago. Like a Dream. Today with beadm(8) and bectl(8) tools and also the FreeBSD loader(8) the ZFS Boot Environments are first class and one of the main features of the FreeBSD operating system.
Back in the more ‘normal’ times (before C19) I was able to talk two times about ZFS Boot Environments. I hope I explained them well.
- 1st in Poland at PBUG meeting – with presentation available HERE.
- 2nd in Holland at NLUUG conference – with presentation available HERE.
I do not know any downsides of ZFS Boot Environments but if you would stick a gun into my head and make me find one – I would say that you still have to reboot(8) to change to the other BE. This is about to change …
Reroot Instead Reboot
What is reroot? Its the ability to switch to other root filesystem without the need for full system reboot. The loaded and running kernel stays the same of course – but this is the only downside. This feature is implemented in the reboot(8) command with -r argument.
As we can read in the FreeBSD 10.3-RELEASE Release Notes page:
The initial implementation of “reroot” support has been added to the reboot(8) utility, allowing the root filesystem to be mounted from a temporary source filesystem without requiring a full system reboot. (r293744) (Sponsored by The FreeBSD Foundation)
How can reroot be useful here? It will save you a lot of time when you did not updated the kernel. There are two types of update strategies when using the ZFS Boot Environments. You can create new BE (as a backup world that you can get back to) and update the running system. Then you can use checkrestart(1) to verify which processes should be restarted because either binaries or libraries has been updated.
The other way was to create new separate BE (while not touching the running one) and then mount it and update that new BE and reboot into it later. This created a need to reboot(8) but not anymore. Especially when you just update the packages with pkg(8) command.
With the new reroot option of beadm(8) you will tell FreeBSD to reroot your running kernel into specified BE. It will definitely have less impact in virtual machines as they reboot quite fast but imagine saved time on a server class physical machine with about 10 minutes lost for BIOS POST messages and initialization … or personal desktop/laptop GELI encrypted system without the need to type in again the GELI password to decrypt it after reboot.
On the screenshot above I use the latest FreeBSD 13.1-BETA1 but it works the same on other production FreeBSD releases such as 12.3-RELEASE or 13.0-RELEASE. The new upgraded beadm(8) is available from its home at GitHub page here:
I will add that updated version to the FreeBSD Ports tree later along with updated man page later.
Usage of this new feature is quite simple. You type beadm reroot BENAME in the terminal and FreeBSD reroots into that BE without reboot. Takes about 9-10 seconds on my 11 years old ThinkPad W520 so it may be even faster on your more up to date system.
# beadm list BE Active Mountpoint Space Created 12.3 - - 9.5G 2021-10-18 13:14 13.0.p6 - - 13.9G 2022-01-27 11:07 13.0 - - 12.9G 2022-03-05 15:02 13.0.safe - - 2.8M 2022-03-08 14:54 13.1 NR / 9.5G 2022-03-12 00:18 13.1.safe - - 544.0M 2022-03-13 23:18 # beadm activate 13.1.safe Activated successfully # beadm reroot 13.1.safe
… and you are going the route similar to typing shutdown now on a running system. All services are stopped. Then root is changed to new one. Then system continues to boot along with starting all its services as usual. Just without the BIOS POST and the bootloader and kernel parts.
The reroot feature is especially useful in one of these scenarios:
From what I know the bectl(8) does not has that reroot feature but maybe it will be added to it somewhere in the future.
Not sure that ZFS Boot Environments Revolutions is the best title for this blog post, but as I used Reloaded on my 2nd ZFS Boot Environments presentation I though that sticking to The Matrix (1999) schema. I could of course do 3rd and updated presentation … but I am afraid that it will not happen … or at least not soon.
I did not thought that the FreeBSD Enterprise Storage presentation that I gave at 2020/02 PBUG would be my last – it was more then 2 years ago.
UPDATE 1 – Faster Upgrade with New beadm(8) Version
Today (2022/05/06) I introduced new beadm(8) version 1.3.5 that comes with new chroot(8) feature. It has already been committed to the FreeBSD Ports tree under 263805 PR so expect packages being available soon.
You can also update beadm(8) directly like that:
# fetch -o /usr/local/sbin/beadm https://raw.githubusercontent.com/vermaden/beadm
Now for the faster update process – here are the instructions depending on the shell you use.
- ZSH / CSH
# beadm create 13.1-RC6 # beadm chroot 13.1-RC6 BE # zsh || csh BE # yes | freebsd-update upgrade -r 13.1-RC6 BE # repeat 3 freebsd-update install BE # exit # beadm activate 13.1-RC6 # reboot
- SH / BASH / FISH / KSH
# beadm create 13.1-RC6 # beadm chroot 13.1-RC6 BE # sh || bash || fish || ksh BE # yes | freebsd-update upgrade -r 13.1-RC6 BE # seq 3 | xargs -I- freebsd-update install BE # exit # beadm activate 13.1-RC6 # reboot
Happy upgrading 🙂