Last time I showed how to tag along a FreeBSD RELEASE, so you always have the latest security patches installed.
This time I’ll go one step further and give you an example on how FreeBSD 7.2-RELEASE-p7 of the Zerouptime Servers is updated to FreeBSD 7.3-RELEASE.
We’ll go again using the “freebsd-update” utility in order to apply binary patching. But since this is a full minor version step, it is recommended to read /usr/src/UPDATING. If you don’t have the source downloaded you may still view it online. Below procedure might work with major release steps too (e.g. upgrade 7.x to 8.x), but then it’s most imperative that you read UPDATING and know what consequences you will face, also the likelyhood that you might have to rebuild the majority of your ports increases.
There are many exhaustive tutorials which give you the full brass of instructions, I’ll keep it simple and stupid (KISS):
The FreeBSD manual pages advise that you must re-install all ports after upgrading even a minor version – forget about it, if a port breaks you can still re-install it if needed.
So we invoke first
# freebsd-update -r 7.3-RELEASE upgrade
It compares now what components that have been installed versus which components that are available and asks you if it looks reasonable to you. If it does, answer ‘y’.
(...) The following components of FreeBSD seem to be installed: kernel/generic src/base src/bin src/cddl src/contrib src/crypto src/etc src/games src/gnu src/include src/krb5 src/lib src/libexec src/release
src/rescue src/sbin src/secure src/share src/sys src/tools src/ubin src/usbin world/base world/dict world/doc world/games world/info world/manpages world/proflibs
The following components of FreeBSD do not seem to be installed: world/catpages Does this look reasonable (y/n)? y
This will download and prepare all files needed for patching in a separate directory and will ask you to merge changed config files. Do NOT skip this merge, else you will experience unpleasant surprises (such as I had ages ago, when tcpwrappers was disabled by default in a newer release and I didn’t bother to look through the diffs of /etc/ssh/sshd_config).
Until now nothing was modified in your system. As soon the previous step has completed you can trigger the installation by issuing
# freebsd-update install
This will install the kernel and modules. After this you must reboot.
# shutdown -r now
Then run again
# freebsd-update install
to install the userland binaries and conclude the upgrade.
You should check now your most important ports to see if they run smoothly. If there is trouble with some, update your ports collection and rebuild the defunct ports.
That’s about it. If needed I may clarify some sections, feedback wanted.
If pkg turns out to terminate with an error like this:
Updating FreeBSD repository catalogue… pkg: repository meta has wrong version 2 pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0 Fetching meta.txz: 100% 916 B 0.9kB/s 00:01 pkg: repository meta has wrong version 2 repository FreeBSD has no meta file, using default settings Fetching packagesite.txz: 100% 6 MiB 910.8kB/s 00:07 pkg: repository meta has wrong version 2 pkg: 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!
The following can be done to remediate the issue:
- Uninstall pkg (yes, it will leave in a statically compiled version to re-install later):
# pkg delete -f pkg Checking integrity… done (0 conflicting) Deinstallation has been requested for the following 1 packages (of 0 packages in the universe): Installed packages to be REMOVED: pkg-1.11.1 Number of packages to be removed: 1 The operation will free 12 MiB. Proceed with deinstalling packages? [y/N]: y [1/1] Deinstalling pkg-1.11.1… [1/1] Deleting files for pkg-1.11.1: 100%
2. Re-install pkg by simply typing “pkg”:
# pkg The package management tool is not yet installed on your system. Do you want to fetch and install it now? [y/N]: y Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:12:amd64/latest, please wait… Verifying signature with trusted certificate pkg.freebsd.org.2013102301… done Installing pkg-1.16.1… Extracting pkg-1.16.1: 100%
Now the installed packages should be updated:
root@baraddur:~ # pkg update Updating FreeBSD repository catalogue… Fetching meta.conf: 100% 163 B 0.2kB/s 00:01 Fetching packagesite.txz: 100% 6 MiB 6.4MB/s 00:01 Processing entries: 100% FreeBSD repository update completed. 30228 packages processed. All repositories are up to date. root@baraddur:~ # pkg upgrade Updating FreeBSD repository catalogue… FreeBSD repository is up to date. All repositories are up to date. Updating database digests format: 100% Checking for upgrades (24 candidates): 100% Processing candidates (24 candidates): 100% The following 25 package(s) will be affected (of 0 checked): New packages to be INSTALLED: (...) Installed packages to be UPGRADED: (...) Installed packages to be REINSTALLED: (...) Number of packages to be installed: 2 Number of packages to be upgraded: 22 Number of packages to be reinstalled: 1 The process will require 120 MiB more space. 171 MiB to be downloaded. Proceed with this action? [y/N]: y
Remove stale dependencies:
root@baraddur:~ # pkg autoremove Checking integrity… done (0 conflicting) Deinstallation has been requested for the following 9 packages: Installed packages to be REMOVED: (...) Number of packages to be removed: 9 The operation will free 422 MiB. Proceed with deinstalling packages? [y/N]: y
And voila – you’re all set!