Upgrading FreeBSD Releases Safely with freebsd-update

Upgrading FreeBSD Releases Safely with freebsd-update

Upgrading FreeBSD Releases Safely with freebsd-update

It is 2am and you are staring at an SSH session into a production FreeBSD box racked in a London datacentre. The maintenance window is booked, the change request is approved, and the only thing standing between you and a fresh major release is a single command. We have all been there — that quiet moment before you type freebsd-update upgrade -r and hope the box comes back. The good news is that with the right preparation, a FreeBSD release upgrade is one of the least dramatic things you will do all year.

Why freebsd-update Is Still Our Go-To Upgrade Tool

Why freebsd-update Is Still Our Go-To Upgrade Tool

freebsd-update is the official binary upgrade path maintained by the FreeBSD Release Engineering team. It downloads signed patches and release sets from a mirror, verifies them against the project’s trusted keys, and applies them without needing a full source tree or a compiler on the box. For UK sysadmins running fleets of servers in London and Manchester datacentres, that predictability matters more than anything else.

Our team manages a mix of physical hardware and jails across two UK colocation sites, and the ability to schedule a 30-minute maintenance window with confidence is worth a great deal. Building from source gives you fine-grained control, but it also gives you a long night and a lot of CPU cycles.

Binary Upgrades vs Building from Source

Building world and kernel from source via make buildworld is a legitimate approach, especially if you carry custom kernel options or patches. But it requires a full source checkout, a working toolchain, and typically an hour or more of compile time on modest hardware — never mind the risk of a failed build at 4am.

freebsd-update skips all of that. It applies pre-built binaries that match the official release, handles the kernel and userland together, and integrates with etcupdate for configuration merges. For standard workloads — web servers, mail relays, jails, ZFS storage nodes — it is almost always the right call.

When freebsd-update Is Not the Right Fit

There are cases where we reach for source builds instead:

  • You run a custom kernel with non-default options such as options IPSEC or altered GENERIC settings.
  • You have applied local patches to base system files that are not in the source tree.
  • You are tracking stable/14 or main rather than a release branch.
  • You need to upgrade a release that has already passed end-of-life and is no longer served by the update infrastructure.

For everyone else, the binary path is faster, safer, and far easier to document for the next person on call.

Pre-Upgrade Checks Every UK Sysadmin Should Run

Preparation is where upgrades are won or lost. Before we touch anything, we run through a short checklist that has saved us more than once.

Verifying Your Current Release and Patch Level

Start by confirming exactly what you are running:

  • freebsd-version -kru — shows the running kernel, the installed kernel, and the userland version separately. Mismatches here are a red flag.
  • uname -a — confirms the kernel build string.
  • pkg -vv | grep -i abi — verifies the package ABI, which must match the release you are upgrading to.

Next, read the release notes and errata for the target version on the FreeBSD website. Pay particular attention to any Upgrade Notes section — that is where breaking changes to rc.conf, devd, or jail configuration tend to hide.

Testing Mirror Reachability from London and Manchester

Before you commit to a window, make sure your chosen mirror is actually reachable and serving the right content. From a shell on the target host:

  1. Run freebsd-update fetch and confirm it completes without timeouts.
  2. Check the ServerName line in /etc/freebsd-update.conf — it should point at a UK-based FreeBSD mirror for speed.
  3. Verify out-of-band access: IPMI, iDRAC, or a serial console. If the network stack fails post-reboot, you need a way back in.

We also confirm that the host has at least a few gigabytes of free space on /var and that no unattended-upgrade cron job will fire mid-window.

Backing Up and Snapshotting Before You Commit

If your root filesystem is ZFS — and on modern FreeBSD installs it usually is — you have one of the best rollback mechanisms in the Unix world sitting right there. Use it.

Creating a ZFS Boot Environment

A boot environment is a clone of your root dataset that you can boot into independently. With beadm installed from ports or packages:

  • beadm create pre-upgrade-14.1 — snapshots and clones the current root.
  • beadm list — confirms the new environment exists and is marked active on reboot.

If you prefer raw ZFS, zfs snapshot zroot/ROOT/default@pre-upgrade gives you a recovery point, though booting from it requires a bit more manual work. We use beadm because it makes the rollback a single command.

Testing the Upgrade in a Jail or VM

Where time allows, we clone the production jail configuration into a bhyve VM or a dedicated test jail and run the full upgrade there first. This surfaces etcupdate conflicts, package breakage, and jail parameter changes before they hit anything customer-facing. A 40-minute dry run in a VM has saved us entire evenings.

Running the freebsd-update Upgrade Step by Step

With snapshots in place and a window booked, the actual upgrade is refreshingly short.

Fetching and Installing Patches

  1. freebsd-update fetch — downloads the latest patch set for your current release.
  2. freebsd-update install — applies those patches. Do this first so you start the upgrade from a fully patched base.
  3. freebsd-update upgrade -r 14.1-RELEASE — fetches the new release. You will be prompted to review and merge configuration changes.
  4. freebsd-update install — installs the new kernel.
  5. shutdown -r now — reboot into the new kernel.
  6. freebsd-update install — a second run installs the new userland. A third run may be needed to remove old shared libraries.

Do not skip the intermediate reboots. Running the new userland against the old kernel is a well-known way to break things.

Handling Configuration File Merges with etcupdate

If you have local modifications to files in /etc, the upgrade will pause and ask you to merge them. Modern FreeBSD uses etcupdate for this:

  • etcupdate diff — shows what differs between your files and the new defaults.
  • etcupdate resolve — walks you through conflicts interactively.
  • etcupdate status — confirms everything is resolved.

Older guides mention mergemaster, which still works but is deprecated. We default to etcupdate on anything running 12.x or later.

Post-Upgrade Validation and Rollback Options

Once the box is back up, the work is not finished. Validation is what separates a clean upgrade from a slow-motion outage.

Checking Services, Jails, and ZFS Pools

Our standard post-upgrade sweep:

  • freebsd-version -kru — confirm kernel and userland now agree on the new release.
  • dmesg — scan for driver errors, missing modules, or ZFS warnings.
  • zpool status — verify all pools are ONLINE and no resilver is needed.
  • service -e and service -l — check that expected services are running.
  • jls — confirm jails started cleanly.
  • pkg bootstrap -f then pkg upgrade — refresh the package manager and reinstall third-party software against the new ABI.

We also tail /var/log/messages for a few minutes and run a quick sockstat -4l to confirm listening services match expectations.

Rolling Back with Boot Environments

If something is genuinely broken — a jail refuses to start, a driver misbehaves, a custom service will not launch — do not fight it at 3am. Reboot into the boot environment you created earlier:

  1. beadm activate pre-upgrade-14.1
  2. shutdown -r now

You are back on the previous release in under two minutes, with all your data intact. Then you can debug the upgrade in daylight or on a staging VM.

Choosing Fast FreeBSD Mirrors in the UK

Download speed matters when you are pulling hundreds of megabytes of base system and packages. A UK-based FreeBSD mirror will typically deliver several times the throughput of a distant European or US mirror, especially during peak hours.

Configuring freebsd-update.conf for Local Mirrors

Edit /etc/freebsd-update.conf and set the ServerName directive to a UK mirror. The official mirror list on the FreeBSD website flags UK hosts, and many UK ISPs and universities maintain public mirrors that carry both freebsd-update content and package repositories.

For packages, edit /etc/pkg/FreeBSD.conf or drop a file into /usr/local/etc/pkg/repos/ pointing url at a UK mirror. If you are still on the older pkgng layout, the equivalent is setting PACKAGESITE in your environment or pkg configuration.

Keeping Packages in Sync After the Upgrade

After the base system is upgraded, your installed packages are still built for the old ABI. Run pkg bootstrap -f followed by pkg upgrade -f to reinstall everything against the new release. On jails, do this inside each jail after the host is confirmed healthy. Pointing pkg at a fast UK mirror makes this step noticeably quicker across a fleet.

FAQ

Can I upgrade FreeBSD without rebooting?

No. A major release upgrade replaces the kernel, and the running kernel cannot be swapped out live. You need at least one reboot, and often two — one after the kernel install and one after the userland install.

How long does a freebsd-update upgrade usually take?

On a typical UK VPS or dedicated server with a fast mirror, expect 15 to 45 minutes for the download and install phases, plus reboots. The dominant factor is your connection to the mirror and the speed of the disk holding /var.

What happens if etcupdate reports a conflict I do not understand?

Do not guess. Keep your existing file, note the conflict, and finish the upgrade. You can revisit the merge later with etcupdate diff. A wrong merge can break boot, whereas a stale config usually just means a service needs a restart.

Is it safe to upgrade a production server in a London datacentre remotely?

Yes, provided you have out-of-band access — IPMI, iDRAC, or a serial console — and a ZFS boot environment to fall back on. We never upgrade a remote box without both. If either is missing, schedule hands-on time or test in a VM first.

Do I need to reinstall packages after upgrading the base system?

Effectively yes. The ABI changes between major releases, so existing packages will not link correctly against the new libraries. Run pkg bootstrap -f and then pkg upgrade -f against a fast UK mirror.

FreeBSD upgrades do not have to be dramatic. With a ZFS boot environment ready, a tested mirror, and a clear command sequence, the whole process becomes routine — the kind of boring maintenance window that lets you close the laptop and get some sleep. That is exactly what we aim for on every box we manage across London and Manchester.

Leave a Reply