How To Use beadm to Upgrade FreeBSD installed in a ZFS Boot Environment, with minimal downtime

If you have ever upgraded FreeBSD from source, you know its a fairly lengthy process (at least waiting for it to compile). There are several steps that must be done while the system is in single user mode, which means its down for users. In my case the majority of places I use FreeBSD is to provide services, Web Services, Proxy Services, DNS Resolution, etc. I don't have users logging into the systems directly, just administration tasks. This isn't how everyone uses it, and this process isn't restricted to just this environment. This process allows those services to stay up during the entire process, right up until the system is rebooted. Interruption of the services is very minimal, just a few minutes.

This process isn't limited to FreeBSD updates, I also use it to create a restore point for port updates as well. It has saved plenty of time on a few occasions when an update broke a service and I was able to bring everything back on line in minutes. Then research the problem, test fixes without user interruption, and bring the new updated version back on line after hours with the fix in place.

This method, isn't restricted to using source to do the updates, or using ports, this process will work with freebsd-update and binary packages as well. The examples will be done using buildworld to update the operatign system, and portmaster to update ports since that is the method I use.

Its worth pointing out before we go any farther, you have to keep in mind what you are hosting on the server. How the data is stored, if additional port updates are done what additional steps may be required. For instance I use PostgreSQL for some things, if I also update the PostgreSQL version sometimes a backup and restore is required which can increase downtime.

This example also makes use of a jail as part of the process, Most of the jails configuration will be glossed over along with the build & install commands, it is expected that you are already familiar with these processes.