Update FreeBSD

Prepare

Backup

TODO: freebsd-update takes snapshots automatically so it is not needed when upgrading host. But maybe it makes sense for jails.

zfs snapshot

Make backup of /etc

cp -a /etc/ tmp/etc

Upgrade current release

Check system integrity

freebsd-update IDS > fu-ids.txt

TODO: Check that generic kernel exists

[ -f /boot/GENERIC ] || echo 'There is no generic kernel.'

Update the system

freebsd-update fetch
freebsd-update install

When kernel was changed

shutdown -r +30s

Ugrade to newer release

It is probably good idea to update the current relase to latest bits before upgrade. I mean system and packages.

freebsd-update -r 15.0-RELEASE upgrade

Install new kernel and boot it.

freebsd-update install
shutdown -r +30s

Upgrade system and installed packages.

freebsd-update install
pkg-static upgrade -f

For sure reboot once again.

shutdown -r +30s

Upgrading jails

It seems freebsd-update grabs the current system version from uname and because we update jails after the host was updated it gets latest version from kernel and don’t want to update. It is neccessary to tell it what is real jail release version via --currently-running option. It is probably needed for ugrade and fetch subcommands as described on Wiki: Unadulterated Jails, the Simple Way

jail_name=''
freebsd-update -b "/usr/jail/${jail_name}" -r 15.0-RELEASE --currently-running 14.3-RELEASE-p6 upgrade
freebsd-update -b "/usr/jail/${jail_name}" install # Install kernel
# Reboot is not needed here because new kernel is already running.
freebsd-update -b "/usr/jail/${jail_name}" install # Install user space
pkg -j "${jail_name}"  upgrade -f
service jail restart "${jail_name}"

Before you’ll continue with another jail, verify that everything works, especially services like DNS and LDAP.

From inside or outside

Where are the downloaded files saved to? /var/db/freebsd-update/

When updating jail from host and from inside, does it differs? It seems when updating from host it doesn’t download all the stuff again.

Upgrade zpool

zpool upgrade zroot

Upgrade boot loader

cd /boot/efi/efi/boot
cp -p /boot/loader.efi .
mv bootx64.efi boot64-old.efi && mv loader.efi bootx64.efi
cd /boot/efi/efi/freebsd/
cp -p /boot/loader.efi .

Miscellanous notes

mergemaster -i -U -D /usr/jail/<jail_name>