For the complete documentation index, see llms.txt. This page is also available as Markdown.

13.3 Updating the Base System with PkgBase

The design goal of PkgBase is to enable stable, current, and release (including BETA, RC, etc.) branches to all use a unified binary tool for updates. Previously, the stable and current branches could only be updated by compiling source code.

Note

Only FreeBSD 14.0-RELEASE and later can be directly converted to PkgBase. Older versions still need to be updated via freebsd-update (running pkgbasify will display Unsupported FreeBSD version, meaning the FreeBSD version is not supported).

Warning

This carries risks and may result in the loss of all system data! It is recommended to make a backup before proceeding.

  • Lock the pkg package in the /mnt/upgrade environment to prevent upgrades or modifications:

# pkg -c /mnt/upgrade lock pkg  # Lock the pkg package in the /mnt/upgrade environment
pkg-2.4.2_1: lock this package? [y/N]: y # Enter y and press Enter to confirm locking pkg
Locking pkg-2.4.2_1
  • Download the PkgBase conversion script

# fetch -o /mnt/upgrade https://raw.githubusercontent.com/FreeBSDFoundation/pkgbasify/main/pkgbasify.lua  # Download the PkgBase conversion script
  • Convert using pkgbasify

Warning

After confirming the Do you accept this risk and wish to continue? (y/n) risk prompt, there is no second confirmation step!

# chroot /mnt/upgrade /usr/libexec/flua pkgbasify.lua  # Convert using pkgbasify
Running this tool will irreversibly modify your system to use pkgbase.
This tool and pkgbase are experimental and may result in a broken system.
It is highly recommended to backup your system before proceeding.
Do you accept this risk and wish to continue? (y/n) y # Risk prompt; confirm to continue
Updating FreeBSD repository catalogue...

……Omitted here……

The following 370 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        FreeBSD-acct: 14.3p6 [FreeBSD-base]
        FreeBSD-acct-man: 14.3p6 [FreeBSD-base]
        FreeBSD-acpi: 14.3p6 [FreeBSD-base]
        FreeBSD-acpi-man: 14.3p6 [FreeBSD-base]

……Omitted here……

Conversion finished.

Please verify that the contents of the following critical files are as expected:
/etc/master.passwd
/etc/group
/etc/ssh/sshd_config

After verifying those files, restart the system.
  • Check the system version in the boot environment 15.0-RELEASE

Using PkgBase to Update the System Version in the Boot Environment to 15.0-RELEASE

After converting to PkgBase, you can use the pkg package manager to upgrade the system. Below we configure the PkgBase source and perform the upgrade.

Software source structure:

  • Create the PkgBase software source directory

  • Edit the /mnt/upgrade/usr/local/etc/pkg/repos/FreeBSD-base.conf file and add the PkgBase source

Warning

Please check the contents of FreeBSD-base.conf, especially that you should not manually hardcode any specific version in it (such as base_release_3).

Since FreeBSD 15.0 uses a new signing key, when upgrading from 14.x to 15.0, the fingerprints path must be changed from the pkgbasify default /usr/share/keys/pkg to /usr/share/keys/pkgbase-${VERSION_MAJOR}, and ensure that the pkgbase-15 key is installed (which can be installed via pkg add -f https://pkg.freebsd.org/FreeBSD:15:$(uname -p)/base_release_0/FreeBSD-pkg-bootstrap-15.0.pkg).

Tip

Users who need to switch software sources can change the url line to url: "https://mirrors.ustc.edu.cn/freebsd-pkg/${ABI}/base_release_${VERSION_MINOR}",. Readers concerned with security should keep the default settings.

  • Refresh the software source

  • Use PkgBase to update from 14.3-RELEASE to 15.0-RELEASE (i.e., specify the ABI as 15)

Tip

If no updates are detected, please confirm whether the system has been successfully converted to PkgBase and check whether the software source configuration is correct.

  • Check the system version in the boot environment 15.0-RELEASE

The r showing 14.3-RELEASE is not abnormal; it indicates that the currently running system is still 14.3-RELEASE. Combined with other parameters, it can be seen that the switch to 15.0-RELEASE will only occur after a reboot.

  • Unlock pkg

  • Update the ABI of all third-party packages to FreeBSD 15.0

The update process requires multiple confirmations to complete.

Appendix: Switching Software Sources for the pkgbasify Script (Using USTC)

For users in restricted network environments, it may be necessary to configure a domestic mirror source for the pkgbasify script to improve download speeds. Below describes how to modify the source address in the script.

The University of Science and Technology of China (USTC) provides FreeBSD mirror services. You can modify the pkgbasify script to use this mirror source. For other open-source mirror sites, see the software source chapter. First, you need to find the relevant function in the script.

Find the create_base_repo_conf function in the Lua script:

Modify this function as follows, where the mirror site is specified in the return section:

Warning

Please remove pkg+ from the return "pkg+https://" line, otherwise an error will occur.

Then find the following function create_base_repo_conf

Modify as follows (removed the srv-related lines):

Tip

Readers concerned with security should keep the default settings.

Last updated