Home FreeBSD How To Upgrade To FreeBSD 13 From FreeBSD 12

How To Upgrade To FreeBSD 13 From FreeBSD 12

By sk
Published: Last Updated on 1585 Views

The FreeBSD Release Engineering Team is recently announced the availability of FreeBSD 13.0-RELEASE. This is the first release of the stable/13 branch. FreeBSD 13.0 is shipped with many updated set of features. It supports several architectures including amd64, i386, powerpc, powerpc64, powerpc64le, powerpcspe, armv6, armv7, aarch64, and riscv64. If you prefer a fresh installation, head over to the FreeBSD 13.0 download page and get a suitable version for your architecture. If you already have older versions, you an directly upgrade FreeBSD 12 to FreeBSD 13. In this step by step guide, let us see how to upgrade to FreeBSD 13 from FreeBSD 12.

Update FreeBSD 12

First things first. Take a backup of everything that you can't afford losing. FreeBSD upgrade worked 100% in my case. However, backup the data, just in case.

Check FreeBSD OS version and kernel version using commands:

# freebsd-version -k

Sample output:

12.0-RELEASE-p10
$ uname -mrs

Sample output:

FreeBSD 12.0-RELEASE-p10 amd64
Check FreeBSD OS version and kernel version
Check FreeBSD OS version and kernel version

As you see above, the installed version is FreeBSD 12.0-RELEASE. I haven't updated my FreeBSD test machine for a long time, hence it shows 12.0. The latest version in 12.x branch is 12.2.

Before upgrading to next available major version, we must update our current FreeBSD 12.x version.

To download and install the FreeBSD security patches, run the following commands as root user:

# freebsd-update fetch
# freebsd-update install
# pkg upgrade

Once the packages are upgraded, reboot your system:

# shutdown -r now

Or,

# reboot

It is time to upgrade FreeBSD 12 to FreeBSD 13.

Upgrade to FreeBSD 13 from FreeBSD 12

Run the following command to upgrade to FreeBSD 13.0-RELEASE from FreeBSD 12.x version:

# freebsd-update -r 13.0-RELEASE upgrade

Once you run this command, the freebsd-update command will evaluate the configuration file and current system in an attempt to gather the information necessary to perform the upgrade. During the upgrade, you will be asked what to install, what to remove or how to proceed. You may need to type y and hit ENTER a few times to continue.

Sample output:

 src component not installed, skipped
 Looking up update.FreeBSD.org mirrors… 2 mirrors found.
 Fetching metadata signature for 12.0-RELEASE from update1.freebsd.org… done.
 Fetching metadata index… done.
 Fetching 1 metadata files… done.
 Inspecting system… done.
 The following components of FreeBSD seem to be installed:
 kernel/generic kernel/generic-dbg world/base world/base-dbg world/doc
 world/lib32 world/lib32-dbg
 The following components of FreeBSD do not seem to be installed:
 Does this look reasonable (y/n)? y
 Fetching metadata signature for 13.0-RELEASE from update1.freebsd.org… done.
 Fetching metadata index… done.
 Fetching 1 metadata patches. done.
 Applying metadata patches… done.
 Fetching 1 metadata files… 
[...]
Upgrade to FreeBSD 13 from FreeBSD 12
Upgrade to FreeBSD 13 from FreeBSD 12

The above command will start to download all packages. Sit back and relax. It will take a while depending upon the speed of your Internet connection.

During the upgrade task, Configuration files will then be merged. The results of every successful merge will be shown to the user as the process continues. Please note that the current system is not being altered yet, because all merging and patching is happening in another directory.

Once all patches have been applied successfully, all configuration files have been merged, run the following command to commit all changes to the disk:

# freebsd-update install

Sample output:

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.
Commit the patches and updates to disk in FreeBSD
Commit the patches and updates to disk in FreeBSD

All Kernel updates have been installed in your FreeBSD. You need to reboot your system to apply the patches.

After logging into the system, run the following command again to finish installing updates:

# freebsd-update install

After all updates are installed, you will see the following output:

[...]
Completing this upgrade requires removing old shared object files.
Please rebuild all installed 3rd party software (e.g., programs
installed from the ports tree) and then run "/usr/sbin/freebsd-update install"
again to finish installing updates.

Once again the run the same command to remove old shared libraries and complete FreeBSD 13.0 upgrade task.

# freebsd-update install

Finally, reboot your system to complete the upgrade task.

Verify if FreeBSD 13.0 is upgraded successfully by checking the OS version.

# freebsd-version -k
13.0-RELEASE

And check the FreeBSD Kernel version:

# uname -mrs
FreeBSD 13.0-RELEASE amd64
FreeBSD 13.0 is successfully upgraded
FreeBSD 13.0 is successfully upgraded

Congratulations! We just upgraded to FreeBSD 13.0. We need to do one more thing as well. After a major version upgrade, all installed packages and ports should be upgraded.

Update all installed packages and ports collections using the following commands:

# pkg-static install -f pkg
# pkg bootstrap -f
# pkg update -y
# pkg upgrade -y

That's it. Reboot once again and start using FreeBSD version.

Troubleshooting pkg update error in FreeBSD

After upgrading to FreeBSD 13.0, I got the following error when I try to update the ports collections:

 pkg-static: Warning: Major OS version upgrade detected.  Running "pkg-static install -f pkg" recommended
 Updating FreeBSD repository catalogue…
 pkg-static: repository meta has wrong version 2
 pkg-static: Repository FreeBSD load error: meta cannot be loaded No error: 0
 Fetching meta.txz: 100%    916 B   0.9kB/s    00:01    
 pkg-static: repository meta has wrong version 2
 repository FreeBSD has no meta file, using default settings
 Fetching packagesite.txz: 100%    6 MiB   1.6MB/s    00:04    
 pkg-static: repository meta has wrong version 2
 pkg-static: Repository FreeBSD load error: meta cannot be loaded No error: 0
 Unable to open created repository FreeBSD
 Unable to update repository FreeBSD
 Error updating repositories!

This usually happens when we upgrade 12.0 to 12.1 or 2. To fix this issue, update ports-mgmt/pkg from the ports tree using ports-mgmt/portmaster.

Fetch the ports tree using commands if you haven't done it already:

# portsnap fetch

Sample output:

 Looking up portsnap.FreeBSD.org mirrors… 4 mirrors found.
 Fetching public key from ipv4.aws.portsnap.freebsd.org… done.
 Fetching snapshot tag from ipv4.aws.portsnap.freebsd.org… done.
 Fetching snapshot metadata… done.
 Fetching snapshot generated at Tue Apr 27 00:08:31 UTC 2021:
 552628c35b88d79f5a54b7774ddca0463fde713e43f367          88 MB 3233 kBps    28s
 Extracting snapshot… done.
 Verifying snapshot integrity… done.
 Fetching snapshot tag from ipv4.aws.portsnap.freebsd.org… done.
 Fetching snapshot metadata… done.
 Updating from Tue Apr 27 00:08:31 UTC 2021 to Tue Apr 27 07:42:07 UTC 2021.
 Fetching 5 metadata patches… done.
 Applying metadata patches… done.
 Fetching 0 metadata files… done.
 Fetching 18 patches. 
 (18/18) 100.00%  done.                             
 done.
 Applying patches… 
 done.
 Fetching 0 new ports or files… done.

Next run the following command to download and extract the entire ports tree to the /usr/ports directory.

# portsnap extract

And then run:

# pkg bootstrap -f
# pkg update -f
# pkg upgrade -f

This usually happens when we do minor upgrade i.e. 12.0 to 12. After running pkg bootstrap -f everything worked as expected.

Related read:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More