FreeBSD 13 released: Here is how to upgrade FreeBSD 12 to 13

FreeBSD 13 verfication


The FreeBSD project released FreeBSD version 13. The new version comes with updated software and features for a wild variety of architectures. The latest release provides performance improvements and better support for FreeBSD. One can benefit greatly using an upgraded version of FreeBSD. Let us see what’s new and quickly update FreeBSD 12 to 13 using the CLI.


release note for all features.

How to upgrade FreeBSD 12 to 13

Let us note down the FreeBSD version by running the following commands:
freebsd-version
uname -mrs

Make sure you apply all existing pending updates for FreeBSD 12.x:
# freebsd-update fetch
# freebsd-update install
# pkg upgrade

FreeBSD 13 released: Here is how to upgrade FreeBSD 12 to 13


I already had all updates applied using Ansible, but you may see the update and might need to reboot your FreeBSD system if the kernel patch is installed. See FreeBSD Applying Security Updates Using pkg/freebsd-update for more info.

WARNING: Make sure you backup all important data, config files, and database tables/DBS. The nixCraft is not responsible for any data loss, and upgrading FreeBSD should only be attempted after backing up all data.

Upgrading from previous releases of FreeBSD 12.2 to 13.0 using binary method

I tested the following instructions with my AWS EC2 FreeBSD AMD64 VM. Please note that upgrading powerpc64 systems from earlier FreeBSD Releases is NOT supported. Users need to reinstall, due to using new ABI. Binary upgrades between RELEASE versions are recommended using the freebsd-update command-line utility. Hence, run the following freebsd-update command:
# freebsd-update -r 13.0-RELEASE upgrade

How to ugprade FreeBSD 12 to 13 using the CLI

Binary upgrades started on my FreeBSD EC2 AWS cloud server

The freebsd-update will assess the configuration files and might prompt you as follows for config file merging and other options as per your installed apps and customizations. Read them carefully:

..11090....11100....11110....11120....11130....11140....11150....11160....11170... done.
Applying patches... Fetching 627 files... ....10....20....30....40....50....60....70....80....90....100
...380....390....400....410....420....430....440....450....460....470....480....490
Attempting to automatically merge changes in files... done.
 
The following file will be removed, as it no longer exists in
FreeBSD 13.0-RELEASE: /etc/motd
Does this look reasonable (y/n)? y
......
...
....
/boot/boot1
/boot/boot1.efi
/boot/boot2
/boot/brand-fbsd.4th
/boot/brand.4th
/boot/cdboot
/boot/check-password.4th
/boot/color.4th
/boot/defaults/loader.conf
/boot/delay.4th
/boot/device.hints
/boot/efi
/boot/efi.4th
/boot/frames.4th
/boot/gptboot
To install the downloaded upgrades, run "/usr/sbin/freebsd-update install".

Now that updates are downloaded, merged in a directory, it is time to commit changes to the disk. In other words, type the following command on your FreeBSD box to apply 12 to 13 updates:
# freebsd-update install
Here is what I saw:

src component not installed, skipped
Installing updates...
Kernel updates have been installed. Please reboot and run
"/usr/sbin/freebsd-update install" again to finish installing updates.

Therefore, I reboot the FreeBSD box:
# shutdown -r now
## OR ##
# reboot

My ssh session disconnected:

Connection to ec2.freebsd-nixcraft.wan.sweet.home closed by remote host.
Connection to ec2.freebsd-nixcraft.wan.sweet.home closed.

Removing all old shared libraries and object files

After sometimes the system will come back online, restart the freebsd-update session using the following command:
# freebsd-update install

Updating all apps and packages

Now the base FreeBSD system is fully patched and updated. It is time to update all binary packages too due to ABI changes. We simply run the following pkg command:
# pkg-static install -f pkg
# pkg bootstrap -f
# pkg update
# pkg upgrade

Now I installed all 3rd party apps such as Python, Nginx, and so on. We need to run the following command one more time for removing old shared object files. Hence, make sure one more last time you run the following command and you are done with updating FreeBSD from 12 to 13 using the CLI:
# freebsd-update install
Outputs:

src component not installed, skipped
Installing updates... done.

Is is also possible to upgrade the system using source based method. You need to read the information provided in /usr/src/UPDATING file.
# vim /usr/src/UPDATING

Verifying FreeBSD 12 to 13 upgrade

Make sure all services are running:
# ps aux
# sockstat -l
# sockstat -4
# sockstat -6
# netstat -a -n | grep LISTEN
top

Related: FreeBSD Unix Find Out Which Programs Are Listening On a Given Port Number

Check out for errors in log file using the cat command/grep command/egrep command and other tools:
# tail -f /var/log/messages
# tail -f /var/log/nginx/myapp.log
# grep error /path/to/app
# egrep -i 'err|warn|cri' /var/log/messages

See version:
uname -mrs
freebsd-version

FreeBSD 13 verfication

Remove Unwanted/Unused Dependencies in FreeBSD package (optional)

Upgrade may leave some orphan binary packages, and we can get rid of them too using the pkg command:
# pkg autoremove

How to upgrade FreeBSD jail from 12 to 13

We can upgrade jail too. The concept is the same, but you need to tell the current version as follows. Get jail name and base dir:
# jls
My jail:

 JID IP Address Hostname Path 1 dnscrypt /jails/dnscrypt

Now run :
# freebsd-update -b /jails/dnscrypt/ --currently-running 12.2-RELEASE -r 13.0-RELEASE upgrade
Where,

  1. -b /jails/dnscrypt/ : Operate on a system mounted at jail basedir /jails/dnscrypt/.
  2. --currently-running 12.2-RELEASE : We need to tell freebsd-update like this when using the upgrade command or fetch command for jail upgrades. Do not detect the currently-running release. Only needed when upgrading jails.
  3. -r 13.0-RELEASE upgrade : Specify the new release to which should jail upgrade.

Next, running subsequent jail upgrade and install commands can be done normally with -b for jail dircotry:
## 1. Install downloaded upgrades for jail ##
# freebsd-update -b /jails/dnscrypt/ install
## 2. Reboot/restart our jail ##
# /etc/rc.d/jail restart
# freebsd-update -b /jails/dnscrypt/ install
# jls
## 3. Note down jail id and gain shell ##
# jexec 2 sh
## 4. Upgrade all package inside jail too ##
# pkg-static install -f pkg
# pkg bootstrap -f
# pkg update
# pkg upgrade
## 5. Exit out of jail ##
# exit

Summing up

FreeBSD 13 continues to lead as a robust BSD family of the operating system for end-users. It still maintains classic Unix features while giving out cutting-edge features such as Jails, Bhyve, powerful networking stack, firewalls, and more. I would strongly suggest that you head ahead to the FreeBSD download page and read the release note too.

Posted by Contributor