Upgrade 14.1 Distribution Sets Jail to 15.2 PKGBASE

Wait 5 sec.

More and more FreeBSD systems will need to be converted to PKGBASE world because 15.x line is the last one to have and support older Distribution Sets way of organizing FreeBSD Base System. Usually the process is simple – You upgrade your existing version to 15.x with freebsd-update(8) tool – then convert it to PKGBASE with pkgbasify.lua tool – and then You can live in PKGBASE way with for example pkgbase(8) tool for doing next upgrades or just for applying security patches … but the road was a lot more bumpy for me when I recently upgraded 14.1-RELEASE FreeBSD Jails to PKGBASE world.The Table of Contents for this article looks as follows.Jail Permissions for UpgradeBackup Your JailFetching Needed PatchesUpgrade Processfreebsd-update(8)Workaroundpkgbasify.luapkgbase(8)SummaryJail Permissions for UpgradeI used these permissions during the upgrade process.host # cat /etc/jail.confsrv {# GENERAL host.hostname = "srv.local"; path = "/jail/srv"; devfs_ruleset = "5"; exec.consolelog = "/var/log/jail_console_${name}.log"; exec.clean; exec.start = "/bin/sh /etc/rc"; exec.stop = "/bin/sh /etc/rc.shutdown"; mount.devfs; allow.raw_sockets; enforce_statfs = "1"; persist; allow.chflags;# VNET/VIMAGE vnet; vnet.interface = "${if}b";# NETWORKS/INTERFACES $id = "110"; $ip = "10.1.1.${id}/24"; $gw = "10.1.1.1"; $br = "vm-public"; $if = "epair${id}";# ADD TO bridge0 INTERFACE exec.prestart += "ifconfig ${if} create up"; exec.prestart += "ifconfig ${if}a up descr jail:${name}"; exec.prestart += "ifconfig ${br} addm ${if}a up"; exec.start += "ifconfig ${if}b ${ip} up"; exec.start += "route add default ${gw}"; exec.poststop += "ifconfig ${if}a destroy";}host # cat /etc/devfs.rules[devfsrules_jail_vnet=5]add include $devfsrules_hide_alladd include $devfsrules_unhide_basicadd include $devfsrules_unhide_loginadd include $devfsrules_jailMost important is the allow.chflags permission.Backup Your JailBefore proceeding please backup your Jail – by using recursive ZFS snapshot or even by creating tar(1) archive – please remember to also use -p flag for tar(1) to keep permissions properly.Fetching Needed PatchesI started with usual way – by fetching patches into /var/db/freebsd-update dir.host # jexec srvsrv # rm -rf /var/db/freebsd-updatesrv # mkdir /var/db/freebsd-updatesrv # freebsd-update upgrade --currently-running $( freebsd-version -u ) -r 15.2-RC1src component not installed, skippedLooking up update.FreeBSD.org mirrors... 3 mirrors found.Fetching public key from update1.freebsd.org... done.Fetching metadata signature for 14.1-RELEASE from update1.freebsd.org... done.Fetching metadata index... done.Fetching 2 metadata files... done.Inspecting system... done.The following components of FreeBSD seem to be installed:kernel/generic world/base world/base-dbg world/lib32 world/lib32-dbgThe following components of FreeBSD do not seem to be installed:kernel/generic-dbgDoes this look reasonable (y/n)? yFetching metadata signature for 15.2-RC1 from update1.freebsd.org... done.Fetching metadata index... done.Fetching 1 metadata patches. done.Applying metadata patches... done.Fetching 1 metadata files... done.Inspecting system... done.Preparing to download files... done.Fetching 8286 patches.....10....20....30....40....50....60....70....80....90....100....110....120....130....140....150....160....170....180....190....200....210....220....230....240....250....260....270....280....290....300....310....320....330....340....350....360....370....380....390....4(...)....7930....7940....7950....7960....7970....7980....7990....8000....8010....8020....8030....8040....8050....8060....8070....8080....8090....8100....8110....8120....8130....8140....8150....8160....8170....8180....8190....8200....8210....8220....8230....8240....8250....8260....8270....8280... done.Applying patches... done.Fetching 9842 files... ....10....20....30....40....50....60....70....80....90....100....110....120....130....140....150....160....170....180....190....200....210....220....230....240....250....260....270....280....290....300....310....320....330....340....350....360....370....380....390....(...)9490....9500....9510....9520....9530....9540....9550....9560....9570....9580....9590....9600....9610....9620....9630....9640....9650....9660....9670....9680....9690....9700....9710....9720....9730....9740....9750....9760....9770....9780....9790....9800....9810....9820....9830....9840. done.… and if You think You will miss these patch numbers flying in terminal … You can always get my freebsd-update(8) screensaver Upgrade ProcessFirst the part of updating to 15.x line with freebsd-update(8) tool.freebsd-update(8)Now – we have all needed files under /var/db/freebsd-update dir – lets do next official step.host # jexec srvsrv # freebsd-version -u 14.1-RELEASE-p2srv # freebsd-update installsrc component not installed, skippedInstalling updates...Kernel updates have been installed. Please reboot and run'freebsd-update [options] install' again to finish installing updates.The first step is probably useless in a Jail – but freebsd-update(8) tool does that anyway. Next the FreeBSD userland. You do not need to reboot as Jails use FreeBSD host kernel anyway … but do not execute that freebsd-update install yet – because if You do – You will end up with something like that:srv # freebsd-update installsrc component not installed, skippedInstalling updates...ld-elf.so.1: Shared object "libsys.so.7" not found, required by "libc.so.7"ld-elf.so.1: Shared object "libsys.so.7" not found, required by "libc.so.7"ld-elf.so.1: Shared object "libsys.so.7" not found, required by "libc.so.7"ld-elf.so.1: Shared object "libsys.so.7" not found, required by "libc.so.7"(...)The message about libsys.so.7 will be repeated multiple times more – but more important thing is that now You jail is unusable and will not boot again. Its a know problem described in the 289769 bug report.This is why I asked You do to backup of Your Jail before starting this process.WorkaroundThe hint for that is also in that 289769 bug report.First we need to fetch(1) the base.txz for the 15.2-RC1 version and use lib/libsys.so.7 file from it before upgrading.host # fetch -o /jail/BASE/15.2-RC1-base.txz https://download.freebsd.org/releases/amd64/15.2-RC1/base.txzhost # tar -C /jail/srv/root -xvf /jail/BASE/15.2-RC1-base.txz lib/libsys.so.7x ./lib/libsys.so.7host # jexec srvsrv # cp /root/lib/libsys.so.7 /lib/libsys.so.7Now … You still can not proceed with freebsd-update install … because You will hit another problem. For some reason unknown to me the etcupdate(8) are not created – take a look.srv # freebsd-update installsrc component not installed, skippedInstalling updates...install: ///var/db/etcupdate/current/etc/devd: No such file or directoryinstall: ///var/db/etcupdate/current/etc/devd: No such file or directoryinstall: ///var/db/etcupdate/current/etc/devd: No such file or directoryinstall: ///var/db/etcupdate/current/etc/devd: No such file or directoryinstall: ///var/db/etcupdate/current/etc/dma: No such file or directoryinstall: ///var/db/etcupdate/current/etc/rc.d: No such file or directoryinstall: ///var/db/etcupdate/current/etc/rc.d: No such file or directoryinstall: ///var/db/etcupdate/current/etc/rc.d: No such file or directory(...)We will create them manually.srv # mkdir -p \ /var/db/etcupdate/current/boot \ /var/db/etcupdate/current/root \ /var/db/etcupdate/current/var/crash \ /var/db/etcupdate/current/usr/share/nls \ /var/db/etcupdate/current/etc/autofs \ /var/db/etcupdate/current/etc/bluetooth \ /var/db/etcupdate/current/etc/cron.d \ /var/db/etcupdate/current/etc/defaults \ /var/db/etcupdate/current/etc/devd \ /var/db/etcupdate/current/etc/dma \ /var/db/etcupdate/current/etc/gss \ /var/db/etcupdate/current/etc/kyua \ /var/db/etcupdate/current/etc/mail \ /var/db/etcupdate/current/etc/mtree \ /var/db/etcupdate/current/etc/newsyslog.conf.d \ /var/db/etcupdate/current/etc/pam.d \ /var/db/etcupdate/current/etc/periodic/daily \ /var/db/etcupdate/current/etc/periodic/weekly \ /var/db/etcupdate/current/etc/periodic/monthly \ /var/db/etcupdate/current/etc/periodic/security \ /var/db/etcupdate/current/etc/pkg \ /var/db/etcupdate/current/etc/ppp \ /var/db/etcupdate/current/etc/rc.d \ /var/db/etcupdate/current/etc/security \ /var/db/etcupdate/current/etc/ssh \ /var/db/etcupdate/current/etc/ssl \ /var/db/etcupdate/current/etc/syslog.dThe comment in the 289769 bug report also suggests adding /rescue so we will also do that … and finally proceed with the freebsd-update install command. Pick the variant for Your shell.// csh(1)srv # set path= ( /rescue $path )// sh(1)srv # export PATH=/rescue:${PATH}Now for the update.srv # echo ${PATH}/rescue:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin// UPGRADE (1/4) - kernel (not needed in Jails - just official freebsd-update(8) step)srv # freebsd-update installsrc component not installed, skippedInstalling updates...Kernel updates have been installed. Please reboot and run'freebsd-update [options] install' again to finish installing updates.// UPGRADE (2/4) - userlandsrv # freebsd-update installsrc component not installed, skippedInstalling updates...Completing this upgrade requires removing old shared object files.Please rebuild all installed 3rd party software (e.g., programsinstalled from the ports tree) and then run'freebsd-update [options] install' again to finish installing updates.// UPGRADE (3/4) - pkg(8) packagessrv # pkg upgrade// UPGRADE (4/4) - remove old shared object filessrv # freebsd-update installsrc component not installed, skippedInstalling updates... done.srv # freebsd-version 15.2-RC1-p1Voila!Lets restart the Jail.srv # exithost # /etc/rc.d/jail onestop srvhost # /etc/rc.d/jail onestart srvhost # jexec srvsrv # freebsd-version -r -u15.2-RC115.2-RC1-p1Looks and works well.for the record … none of these run from the host was able to do the upgrade.host # freebsd-update -b /jail/srv -d /jail/srv/var/db/freebsd-update installpkg: Warning: Major OS version upgrade detected. Running "pkg bootstrap -f" recommendedsrc component not installed, skippedNo updates are available to install.Run 'freebsd-update [options] fetch' first.host # freebsd-update -j srv install pkg: Warning: Major OS version upgrade detected. Running "pkg bootstrap -f" recommendedsrc component not installed, skippedNo updates are available to install.Run 'freebsd-update [options] fetch' first.pkgbasify.luaFortunately this one works well – one crucial thing – we need to do it from the host.host # fetch https://github.com/FreeBSDFoundation/pkgbasify/raw/refs/heads/main/pkgbasify.luahost # chmod +x ./pkgbasify.luahost # pkgbasify.lua --jail srvRunning 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) yUpdating FreeBSD-ports repository catalogue...FreeBSD-ports repository is up to date.Updating FreeBSD-ports-kmods repository catalogue...FreeBSD-ports-kmods repository is up to date.Updating FreeBSD-base repository catalogue...FreeBSD-base repository is up to date.All repositories are up to date.(...)[494/495] Extracting FreeBSD-libarchive-lib32-15.2.rc1.20261127045722: 100%[495/495] Reinstalling FreeBSD-set-lib32-15.2.rc1.20261127045722...==> Running trigger: mandoc.ucl=====Message from FreeBSD-local-unbound-15.2.rc1.20261127045722:--After upgrading local-unbound, the configuration file should be regeneratedby running "service local_unbound setup" before restarting the service.Conversion finished.Please verify that the contents of the following critical files are as expected:/jail/srv/etc/master.passwd/jail/srv/etc/group/jail/srv/etc/ssh/sshd_configAfter verifying those files, restart the system.This one was really straightforward – but not fast – it took a while to fetch and convert all parts of FreeBSD Base System.Lets try how it runs after conversion to PKGBASE world.host # /etc/rc.d/jail onestop srvhost # /etc/rc.d/jail onestart srvhost # jexec srvsrv # pkgbase info hostname: srv.local kernel: 15.2-RC1 (running) kernel: N/A (jail) userland: 15.2-RC1 (installed)Yep – works like a charm … and above You see mine pkgbase(8) tool in 1.0 version with some additional Jail improvements that I will share shortly.pkgbase(8)Now You can use pkgbase(8) for applying security patches or upgrading to next versions of FreeBSD.jail # pkgbase patchINFO: will update to latest patch level for '15.2-RC1' versionINFO: devfs(5) filesystem mounted at /dev dirINFO: ZFS Boot Environment creation is disabledUpdating FreeBSD-ports repository catalogue...[srv.local] Fetching meta.conf: 100% 168 B 0.2 kB/s 00:01 [srv.local] Fetching data: 100% 9194 KiB 1.3 MB/s 00:07 Processing entries: 100%FreeBSD-ports repository update completed. 38138 packages processed.[srv.local] Fetching files: 100% 29 MiB 1.7 MB/s 00:18 Compressing files: 100%FreeBSD-ports is up to date.Checking integrity... done (0 conflicting)Your packages are up to date.Updating FreeBSD-base repository catalogue...FreeBSD-base repository is up to date.FreeBSD-base is up to date.Checking for upgrades (1 candidates): 100%Processing candidates (1 candidates): 100%Checking integrity... done (0 conflicting)Your packages are up to date.Updating FreeBSD-ports-kmods repository catalogue...[srv.local] Fetching meta.conf: 100% 168 B 0.2 kB/s 00:01 [srv.local] Fetching data: 100% 45 KiB 46.1 kB/s 00:01 Processing entries: 100%FreeBSD-ports-kmods repository update completed. 290 packages processed.FreeBSD-ports-kmods is up to date.Checking for upgrades (0 candidates): 100%Processing candidates (0 candidates): 100%Checking integrity... done (0 conflicting)Your packages are up to date.INFO: no new patches/packages has been applied by pkgbase(8) toolSeems no updates at this time.SummaryThe PKGBASE looks better and batter – and now You have all the instructions needed to move into this world when needed.EOF