Although the upgrade process is very well described on the FreeBSD handbook you may be looking for a more detailed hands on how to upgrade FreeBSD from version 11.2 up to 12.0 article. We’re going work here on this process, step by step detailing not only how to upgrade but to do it safely.
First of all we have to make a distinction between the two natively supported types of file system FreeBSD has. They are UFS (Unix File System) and ZFS (Zettabyte File System). This is depending on the file system type the process varies a bit. As always a good backup of all the important data is a must prior to any update/upgrade intervention.
A word of warning for those using FreeBSD on non bare-metal boxes. If you happen to be using FreeBSD on virtualized environments with hypervisors such as KVM, Xen or even Hyper-V (on Azure by the way support for FreeBSD is offered), boot environments (beadm) may not be supported at all.
If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.
A word now for the fainhearted Linux admins looking at FreeBSD with scepticism. Do yourself a favour and just read section 6 where you will see the real deal of FreeBSD and ZFS. After that, and if willing for more, you can also read a past article of some other related benefits.
The standard upgrade proccess can be summarized as:
1.- Update the current version in use up to the latest patch.
1.1 Create a new boot environment and boot into it (option only available on ZFS).
2.- Download all the upgrade files.
3.- Perform the upgrade files installation.
4.- Perform the packages updates.
5.- Check versions and functionality are correct.
6.- Rollback options in case the upgrade wasn’t successful.
1.- Update the current version in use up to the latest patch.
First we will check our current system version.
albert@BSD:~ % uname -a
FreeBSD BSD 11.2-RELEASE-p4 FreeBSD 11.2-RELEASE-p4 #0: Thu Sep 27 08:16:24 UTC 2018
[email protected]:/usr/obj/usr/src/sys/GENERIC amd64
albert@BSD:~ %
We’ll perform the update to the latest security patch set for the 11.2 version. For ZFS powered systems an already avaiable article may suit you better. Then come back to section 1.1 of this article straight away. For UFS powered systems read on.
For the sake of completion a UFS disk setup is presented here.
albert@BSD:~ % gpart show
=> 40 67108784 ada0 GPT (32G)
40 1024 1 freebsd-boot (512K)
1064 62913536 2 freebsd-ufs (30G)
62914600 3354624 3 freebsd-swap (1.6G)
66269224 839600 - free - (410M)
albert@BSD:~ %
As you can observe the partition table layout is made with GPT instead of MBR but they’d look the same. Partition 1 is destined to boot the system and 512K are attributed. Partition number 2 allocates 30G of the UFS file system. The SWAP partition allocates 1.6G.
In order to get the latest security patch set for the current version we will use the freebsd-update command with the fetch option.
albert@BSD:~ % sudo freebsd-update fetch
src component not installed, skipped
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching metadata signature for 11.2-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.
Fetching 2 metadata patches.. done.
Applying metadata patches... done.
Inspecting system... done.
Preparing to download files... done.
Fetching 26 patches.....10....20... done.
Applying patches... done.
The following files will be updated as part of updating to 11.2-RELEASE-p7:
/bin/freebsd-version
/boot/check-password.4th
/boot/kernel/kernel
/boot/kernel/nfscommon.ko
/boot/kernel/nfsd.ko
/boot/kernel/zfs.ko
/lib/libzpool.so.2
/rescue/[
/rescue/atmconfig
/rescue/badsect
/rescue/bsdlabel
....…
If you press enter, the new downloaded files will be shown step by step. If you press ‘q’ for quit no more details will be shown and you will be able to carry on the update.
Now it’s time to apply those patches by installing them.
albert@BSD:~ % sudo freebsd-update install
src component not installed, skipped
Installing updates... done.
albert@BSD:~ %
Once they have been applied it is time to reboot the machine, specially if the kernel has been updated so the latest available changes are applied from boot time. You are currently running the old kernel without the new patches, even if you have installed them.
albert@BSD:~ % sudo shutdown -r now
Shutdown NOW!
shutdown: [pid 5900]
albert@BSD:~ %
*** FINAL System shutdown message from albert@BSD ***
System going down IMMEDIATELY
System shutdown time has arrived
After rebooting check your operating system version and compare it to the previous one. It should’ve changed sub-version numbers. We were first running FreeBSD 11.2 p4 and now we should be running FreeBSD 11.2 p7.
albert@BSD:~ % uname -a
FreeBSD BSD 11.2-RELEASE-p7 FreeBSD 11.2-RELEASE-p7 #0: Tue Dec 18 08:29:33 UTC 2018
[email protected]:/usr/obj/usr/src/sys/GENERIC amd64
albert@BSD:~ %
As a last recommendation before the upgrade we should update all the installed packages. Your output may vary since you may have a ton of other programs installed.
albert@BSD:~ % sudo pkg upgrade
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
Fetching packagesite.txz: 100% 6 MiB 1.4MB/s 00:05
Processing entries: 100%
FreeBSD repository update completed. 32580 packages processed.
All repositories are up to date.
Checking for upgrades (1 candidates): 100%
Processing candidates (1 candidates): 100%
The following 1 package(s) will be affected (of 0 checked):
Installed packages to be UPGRADED:
ca_root_nss: 3.39 -> 3.41
Number of packages to be upgraded: 1
290 KiB to be downloaded.
Proceed with this action? [y/N]: y
...........
albert@BSD:~ %
1.1 Create a new boot environment and boot into it.
(Option only available on ZFS, for UFS systems catch the read on the 2nd step).
On ZFS on root powered systems, as already recommended on a previous article, we will make use of a tool called ‘boot environments’ or beadm for short. This tool leverages the ZFS file system capabilities so we will first create a new boot environment, boot into it, perform the upgrade there.
If we still haven’t installed the beadm tool previously it is now the time to do so.
albert@BSD:~ % sudo pkg install beadm
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
beadm: 1.2.9_1
Number of packages to be installed: 1
9 KiB to be downloaded.
Proceed with this action? [y/N]: y
[BSD] [1/1] Fetching beadm-1.2.9_1.txz: 100% 9 KiB 9.6kB/s 00:01
Checking integrity... done (0 conflicting)
[BSD] [1/1] Installing beadm-1.2.9_1...
[BSD] [1/1] Extracting beadm-1.2.9_1: 100%
albert@BSD:~ %
We should now create a boot environment named after the new version of FreeBSD we prettend to upgrade to.
albert@BSD:~ % sudo beadm create 12.0-RELEASE
Created successfully
albert@BSD:~ %
The next step is activating that boot environment we’ve just created so we boot into it on the next reboot.
albert@BSD:~ % sudo beadm activate 12.0-RELEASE
Activated successfully
albert@BSD:~ %
Before rebooting we must check it has been correctly added and activated.
albert@BSD:~ % sudo beadm list
BE Active Mountpoint Space Created
default - - 62.3M 2018-08-04 23:10
11.2-RELEASE-p2 - - 1.1M 2018-08-19 18:43
11.2-RELEASE-p4 - - 36.5M 2018-10-25 21:04
11.2-RELEASE-p7 N / 384.0K 2018-12-21 21:19
12.0-RELEASE R - 872.0M 2018-12-21 21:37
albert@BSD:~ %
As you can see on this system I had already made use of this tool and there are some other boot environments. The ‘N’ flag next to the boot environment name marks the active snapshot. The ‘R’ flag marks the one boot environment which will be active after the reboot.
We shall now reboot into that boot environment and check we are on the correct one.
albert@BSD:~ % sudo shutdown -r now
Shutdown NOW!
shutdown: [pid 956]
*** FINAL System shutdown message from albert@BSD ***
System going down IMMEDIATELY
System shutdown time has arrived
Once logged back in we check we are on the desired boot environment by simply listing them again.
albert@BSD:~ % sudo beadm list
BE Active Mountpoint Space Created
default - - 62.3M 2018-08-04 23:10
11.2-RELEASE-p2 - - 1.1M 2018-08-19 18:43
11.2-RELEASE-p4 - - 36.5M 2018-10-25 21:04
11.2-RELEASE-p6 - - 524.0K 2018-12-21 21:19
12.0-RELEASE NR / 872.0M 2018-12-21 21:37
albert@BSD:~ %
Now both flags ‘N’ and ‘R’ are placed next to the latest boot environment, named after the release we desire to upgrade the system to.
Time to move forwared on this how to upgrade FreeBSD from version11.2 up to 12.0 and get the upgrade files.
2.- Download all the upgrade files.
Again we will make use of the freebsd-update command and the fetch option but we will now specify the release we want to upgrade to.
albert@BSD:~ % sudo freebsd-update -r 12.0-RELEASE upgrade
src component not installed, skipped
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching metadata signature for 11.2-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 world/base world/doc world/lib32
The following components of FreeBSD do not seem to be installed:
kernel/generic-dbg world/base-dbg world/lib32-dbg
Does this look reasonable (y/n)? y
Fetching metadata signature for 12.0-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files..
Inspecting system…
The system will get the necessary files for the merge and the full upgrade.
Fetching files from 11.2-RELEASE for merging... done.
Preparing to download files... done.
Fetching 8786 patches.....10....20....30....40....50....60....70....80….
Depending on the bandwith the box has this process can take from several minutes to a few hours. Grab your favourite drink and watch.
....8760....8770....8780... done.
Applying patches...
Patch fetching ends but then a few more upgrade files download comences.
Applying patches... done.
Fetching 1117 files...
After the download the system will report back a few of the necessary changes from version 11.2 to 12 and will ask for approval.
Attempting to automatically merge changes in files... done.
The following changes, which occurred between FreeBSD 11.2-RELEASE and
FreeBSD 12.0-RELEASE have been merged into /etc/master.passwd:
--- current version
+++ new version
@@ -1,6 +1,6 @@
-# $FreeBSD: releng/11.2/etc/master.passwd 299365 2016-05-10 12:47:36Z bcr $
+# $FreeBSD: releng/12.0/etc/master.passwd 337882 2018-08-15 23:18:34Z brd $
#
root:$6$vWiWF1jupURcgmyI$kK9uHVHqDPi0oHtEuhtdg6xQZnPzvynnSthccmcXkisRe3UDSXAPOCOfC/uoRGhibghB6a.FhY8SvYhEEsrdq0:0:0::0:0:Charlie &:/root:/bin/csh
toor:*:0:0::0:0:Bourne-again Superuser:/root:
daemon:*:1:1::0:0:Owner of many system processes:/root:/usr/sbin/nologin
operator:*:2:5::0:0:System &:/:/usr/sbin/nologin
@@ -20,9 +20,10 @@
_dhcp:*:65:65::0:0:dhcp programs:/var/empty:/usr/sbin/nologin
uucp:*:66:66::0:0:UUCP pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucico
pop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologin
auditdistd:*:78:77::0:0:Auditdistd unprivileged user:/var/empty:/usr/sbin/nologin
www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologin
+ntpd:*:123:123::0:0:NTP Daemon:/var/db/ntp:/usr/sbin/nologin
_ypldap:*:160:160::0:0:YP LDAP unprivileged user:/var/empty:/usr/sbin/nologin
hast:*:845:845::0:0:HAST unprivileged user:/var/empty:/usr/sbin/nologin
nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin
albert:$6$8VBWuktVIVaGQKqT$8FkfYFD/UDNqWMjn8wvWEE2GU6K3Q7zaBPwRFSpNFlT.3nO/AFsvNq1.dcEl28bi3ZGOpWDMU/EBDhsDIZWmr/:1001:0::0:0:Albert Valbuena:/home/albert:/bin/tcsh
Does this look reasonable (y/n)? y
Soon after the merge changes are confirmed we are shown the files necessary to be removed for upgrading to the FreeBSD 12.0-RELEASE.
The following files will be removed as part of updating to 12.0-RELEASE-p1:
/bin/rcp
/boot/kernel/bhnd_chipc.ko
/boot/kernel/geom_part_pc98.ko
/boot/kernel/i915.ko
/boot/kernel/if_bwn_pci.ko
/boot/kernel/if_en.ko
/boot/kernel/if_fatm.ko
/boot/kernel/if_hatm.ko
/boot/kernel/if_ixgb.ko
/boot/kernel/if_lmc.ko
/boot/kernel/if_nxge.ko
/boot/kernel/if_patm.ko
/boot/kernel/if_rtwn.ko
/boot/kernel/if_urtwn.ko
/boot/kernel/jedec_ts.ko
/boot/kernel/libmbpool.ko
/boot/kernel/mcd.ko
/boot/kernel/ng_atm.ko
/boot/kernel/radeon.ko
/boot/kernel/random_yarrow.ko
/boot/kernel/rtwn-rtl8192cfwU_B.ko
/boot/kernel/scd.ko
/boot/kernel/si.ko
/boot/kernel/siba_bwn.ko
/boot/kernel/t3_tom.ko
/boot/kernel/urtwn-rtl8188eufw.ko
/boot/kernel/urtwn-rtl8192cfwT.ko
/boot/kernel/urtwn-rtl8192cfwU.ko
/boot/kernel/utopia.ko
/boot/kernel/vxge.ko
/boot/loader.help
/etc/apmd.conf
/etc/casper
/etc/casper/system.dns
/etc/casper/system.grp
If you press enter, the new downloaded files will be shown step by step. If you press ‘q’ for quit no more details will be shown and you will be able to carry on the update.
Afterwards the new files to be added for the FreeBSD 12.0-RELEASE-p1 upgrade will be shown:
The following files will be added as part of updating to 12.0-RELEASE-p1:
/boot/efi.4th
/boot/kernel/ath_dfs.ko
/boot/kernel/ath_hal.ko
/boot/kernel/ath_hal_ar5210.ko
/boot/kernel/ath_hal_ar5211.ko
/boot/kernel/ath_hal_ar5212.ko
/boot/kernel/ath_hal_ar5416.ko
/boot/kernel/ath_hal_ar9300.ko
/boot/kernel/ath_main.ko
/boot/kernel/ath_rate.ko
/boot/kernel/blake2.ko
/boot/kernel/ccp.ko
/boot/kernel/ccr.ko
/boot/kernel/dtaudit.ko
/boot/kernel/if_iavf.ko
/boot/kernel/if_muge.ko
/boot/kernel/if_qlnxev.ko
/boot/kernel/if_rtwn_pci.ko
/boot/kernel/if_rtwn_usb.ko
/boot/kernel/iwm3168fw.ko
/boot/kernel/mac_ntpd.ko
/boot/kernel/nvdimm.ko
/boot/kernel/rtwn-rtl8188eufw.ko
/boot/kernel/rtwn-rtl8192cfwE.ko
/boot/kernel/rtwn-rtl8192cfwE_B.ko
/boot/kernel/rtwn-rtl8192cfwT.ko
/boot/kernel/rtwn-rtl8192eufw.ko
/boot/kernel/rtwn-rtl8812aufw.ko
/boot/kernel/rtwn-rtl8821aufw.ko
/boot/kernel/rtwn.ko
/boot/kernel/sgx.ko
/boot/kernel/sgx_linux.ko
/boot/kernel/uhid_snes.ko
/boot/kernel/vmci.ko
/boot/loader_4th
If you press enter, the new downloaded files will be shown step by step. If you press ‘q’ for quit no more details will be shown and you will be able to carry on the update.
Almost finally the list of files that will be updated makes its appearance.
The following files will be updated as part of updating to 12.0-RELEASE-p1:
/.cshrc
/.profile
/COPYRIGHT
/bin/[
/bin/cat
/bin/chflags
/bin/chio
/bin/chmod
/bin/cp
/bin/csh
/bin/date
/bin/dd
/bin/df
/bin/domainname
/bin/echo
/bin/ed
/bin/expr
/bin/freebsd-version
/bin/getfacl
/bin/hostname
/bin/kenv
/bin/kill
/bin/link
/bin/ln
/bin/ls
/bin/mkdir
/bin/mv
/bin/pax
/bin/pgrep
/bin/pkill
/bin/ps
/bin/pwait
/bin/pwd
/bin/realpath
/bin/red
If you press enter, the new downloaded files will be shown step by step. If you press ‘q’ for quit no more details will be shown and you will be able to carry on the update.
Finally the system has all the new files and it is now time to perform the install.
To install the downloaded upgrades, run "/usr/sbin/freebsd-update install".
albert@BSD:~ %
3.- Perform the upgrade files installation.
As shown on the prompt we proceed with the upgrade.
albert@BSD:~ % sudo /usr/sbin/freebsd-update install
src component not installed, skipped
Installing updates…
Once finished the system will let us know and will ask for a reboot and a new action to finish with the installation of the upgrade.
Installing updates...
Kernel updates have been installed. Please reboot and run
"/usr/sbin/freebsd-update install" again to finish installing updates.
albert@BSD:~ %
Lets reboot and log back in.
albert@BSD:~ %
*** FINAL System shutdown message from albert@BSD ***
System going down IMMEDIATELY
System shutdown time has arrived
…………….
albert@BSD:~ %
After rebooting we can effectively check we are booted into a FreeBSD 12 version system.
albert@BSD:~ % uname -a
FreeBSD BSD 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC amd64
albert@BSD:~ %
But the upgrade hasn’t finished yet. Let’s apply the final changes.
albert@BSD:~ % sudo /usr/sbin/freebsd-update install
src component not installed, skipped
Installing updates…
And when the upgrade finishes succesfully one is granted with the following message.
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.
albert@BSD:~ %
4.- Perform the packages updates.
You may be wondering what’s that of ‘rebuild all installed 3er party sofware’ and so on. FreeBSD as other UNIX systems do, doesn’t break ABI (Application Binary Interface) during a branch life time. That means the ABI remains stable for applications for a whole version, from the stable release to the final minor version. However it may happen between major version upgrades like the one we are doing here in this how to upgrade FreeBSD from version 11.2 up to 12.0 guide. This means if you happen to install software from ports you will have to rebuild all that software. This can be a long time consuming process as well as tedious. This is why often times, specially for desktop use, using already packaged binaries with the ‘pkg’ tool is recommended. Saving time and bein on the ‘safer’ side is always good. However if you maintain your own repository with poudriere you may be very aware of the new steps to take.
For those using ports in order to get third party applications you can rebuild those by issuing the following portmaster command.
sudo portmaster -afdy --no-confirm
The ‘–no-confirm’ option states not to ask the user for the installation and configuration options typical of using ports to install software.
The ‘-a’ flag will check all the ports and update as necessary, the man page states.
The ‘f’ flag mandates to rebuild the ports.
The ‘d’ flag tells the system to always clean the distfiles.
The ‘y’ flag makes the system to answer yes to all user prompts.
For the rest of us who are using the pkg binary collection we will just update our packages like so.
albert@BSD:~ % sudo pkg-static install -f pkg
pkg-static: Warning: Major OS version upgrade detected. Running "pkg-static install -f pkg" recommended
Updating FreeBSD repository catalogue...
pkg-static: Repository FreeBSD has a wrong packagesite, need to re-create database
Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
Fetching packagesite.txz: 100% 6 MiB 162.8kB/s 00:40
Processing entries: 100%
FreeBSD repository update completed. 31475 packages processed.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):
Installed packages to be REINSTALLED:
pkg-1.10.5_5 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
Number of packages to be reinstalled: 1
3 MiB to be downloaded.
Proceed with this action? [y/N]: y
As you can read the system is aware of the ABI changes from this major upgrade. If you happen to have several packages installed like say, the Apache web server it is more likely that you are presented with something more substantial such as:
pkg: Warning: Major OS version upgrade detected. Running "pkg-static install -f pkg" recommended
Updating FreeBSD repository catalogue...
pkg: Repository FreeBSD has a wrong packagesite, need to re-create database
Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
Fetching packagesite.txz: 100% 6 MiB 1.3MB/s 00:05
Processing entries: 100%
FreeBSD repository update completed. 32180 packages processed.
All repositories are up to date.
Checking for upgrades (14 candidates): 100%
Processing candidates (14 candidates): 100%
The following 14 package(s) will be affected (of 0 checked):
Installed packages to be REINSTALLED:
pkg-1.10.5_5 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
sudo-1.8.26 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
readline-7.0.5 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
perl5-5.28.1 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
pcre-8.42_1 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
libxml2-2.9.7 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
libnghttp2-1.35.1 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
indexinfo-0.3.1 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
gettext-runtime-0.19.8.1_2 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
gdbm-1.18.1 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
expat-2.2.6_1 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
db5-5.3.28_7 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
apr-1.6.5.1.6.1_1 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
apache24-2.4.37 (ABI changed: 'freebsd:11:x86:64' -> 'freebsd:12:x86:64')
Number of packages to be reinstalled: 14
The process will require 2 MiB more space.
38 MiB to be downloaded.
Proceed with this action? [y/N]:y
After positive confirmation the packages are upgraded.
[1/1] Fetching pkg-1.10.5_5.txz: 100% 3 MiB 161.7kB/s 00:21
Checking integrity... done (0 conflicting)
[1/1] Reinstalling pkg-1.10.5_5...
[1/1] Extracting pkg-1.10.5_5: 100%
albert@BSD:~ %
Now it is time to run the freebsd-update install again. ¡Don’t miss this step!
albert@BSD:~ % sudo /usr/sbin/freebsd-update install
src component not installed, skipped
Installing updates...rmdir: ///var/db/etcupdate/current/usr/share/openssl/man/en.ISO8859-1: Directory not empty
rmdir: ///var/db/etcupdate/current/usr/share/openssl/man: Directory not empty
rmdir: ///var/db/etcupdate/current/usr/share/openssl: Directory not empty
rmdir: ///var/db/etcupdate/current/usr/share/man/en.UTF-8: Directory not empty
rmdir: ///var/db/etcupdate/current/usr/share/man/en.ISO8859-1: Directory not empty
rmdir: ///var/db/etcupdate/current/usr/share/man: Directory not empty
done.
albert@BSD:~ %
The upgrade is now finished.
5.- Check versions and functionality are correct.
We can use two different commands to check the version is effectively installed.
albert@BSD:~ % freebsd-version
12.0-RELEASE-p1
albert@BSD:~ %
albert@BSD:~ % uname -a
FreeBSD BSD 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC amd64
albert@BSD:~ %
Another place to look for issues related to the upgrade is inside the /var/log/messages file. If all you can see are regular boot messages like the ones pasted below there is nothing to worry about. If anything is out of place it will usually be marked with an ‘ERROR’ or ‘WARNING’ flag, so don’t be confused with all this jibberish.
albert@BSD:~ % tail /var/log/messages
Dec 21 23:08:43 BSD kernel: Trying to mount root from zfs:zroot/ROOT/12.0-RELEASE []...
Dec 21 23:08:43 BSD kernel: Root mount waiting for: usbus0
Dec 21 23:08:43 BSD kernel: uhub0: 12 ports with 12 removable, self powered
Dec 21 23:08:43 BSD kernel: lo0: link state changed to UP
Dec 21 23:08:43 BSD kernel: em0: link state changed to UP
Dec 21 23:08:43 BSD kernel: intsmb0: <Intel PIIX4 SMBUS Interface> irq 23 at device 7.0 on pci0
Dec 21 23:08:43 BSD kernel: intsmb0: intr IRQ 9 enabled revision 0
Dec 21 23:08:43 BSD kernel: smbus0: <System Management Bus> on intsmb0
Dec 21 23:08:43 BSD kernel: ipfw2 (+ipv6) initialized, divert loadable, nat loadable, default to deny, logging disabled
Dec 21 23:08:43 BSD ntpd[708]: ntpd 4.2.8p12-a (1): Starting
Dec 21 23:08:43 BSD kernel: Security policy loaded: MAC/ntpd (mac_ntpd)
Dec 21 23:08:43 BSD ntpd[709]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): good hash signature
Dec 21 23:08:43 BSD ntpd[709]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): loaded, expire=2017-12-28T00:00:00Z last=2017-01-01T00:00:00Z ofs=37
Dec 21 23:08:43 BSD ntpd[709]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): expired less than 359 days ago
Dec 21 23:08:43 BSD kernel: Dec 21 23:08:43 BSD ntpd[709]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): expired less than 359 days ago
Dec 21 23:10:23 BSD kernel: ipfw: limit 500 reached on entry 65500
albert@BSD:~ %
You can also test the software you are using this box is working too. That includes using commands such as:
ps aux | grep ‘your service name here’
For example let’s check if our Apache web server is working correctly.
albert@BSD:~ % ps aux | grep httpd
root 669 0.0 0.3 16624 5764 - Ss 16:20 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 683 0.0 0.3 16572 5644 - I 16:20 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 684 0.0 0.3 16572 5644 - S 16:20 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 685 0.0 0.3 16572 5644 - I 16:20 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 686 0.0 0.3 16572 5644 - I 16:20 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 687 0.0 0.3 16572 5644 - I 16:20 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
albert 765 0.0 0.0 516 328 0 R+ 16:21 0:00.00 grep httpd
albert@BSD:~ %
And indeed it is working. Let’s look for network connections with ‘netstat’.
albert@BSD:~ % netstat -4
Active Internet connections
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 0 0 192.168.1.105.http 192.168.1.103.53600 ESTABLISHED
tcp4 0 44 192.168.1.105.ssh 192.168.1.101.47228 ESTABLISHED
albert@BSD:~ %
So it’s correctly working, since there is an ssh connection as well as one http since I was browing the server address to check the Apache web server was indeed being ‘spitted out’ to the world.
What about the sockstat command?
albert@BSD:~ % sockstat -4
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
www httpd 771 4 tcp4 *:80 *:*
albert sshd 758 3 tcp4 192.168.1.105:22 192.168.1.101:47228
root sshd 755 3 tcp4 192.168.1.105:22 192.168.1.101:47228
root sendmail 688 3 tcp4 127.0.0.1:25 *:*
www httpd 687 4 tcp4 *:80 *:*
www httpd 686 4 tcp4 *:80 *:*
www httpd 685 4 tcp4 *:80 *:*
www httpd 684 4 tcp4 *:80 *:*
www httpd 683 4 tcp4 *:80 *:*
root httpd 669 4 tcp4 *:80 *:*
root sshd 664 4 tcp4 *:22 *:*
root syslogd 481 7 udp4 *:514 *:*
albert@BSD:~ %
Again, everything seems to be correct and working as it is supposed to be.
Work a bit with the top command too. For the uninitiated to quit from top output, just press the ‘q’. This command lists the CPU consumption, RAM, SWAP use if any and a list of the actual running processess. So if you see any high consumption for an specific process, let’s say a 20% consumption of the httpd service while there are no connections or just one (typically yours) then that would be indicative that there is a problem with that specific application.
albert@BSD:~ % top
last pid: 782; load averages: 0.35, 0.37, 0.21 up 0+00:06:52 16:27:10
28 processes: 1 running, 27 sleeping
CPU: 0.0% user, 0.0% nice, 0.4% system, 0.0% interrupt, 99.6% idle
Mem: 16M Active, 2924K Inact, 57M Wired, 24M Buf, 1882M Free
Swap: 819M Total, 819M Free
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
782 albert 1 20 0 13M 3488K RUN 0:00 0.02% top
410 root 1 20 0 10M 1440K select 0:00 0.01% devd
481 root 1 20 0 11M 2652K select 0:00 0.00% syslogd
758 albert 1 20 0 20M 9128K select 0:00 0.00% sshd
688 root 1 20 0 17M 6944K select 0:00 0.00% sendmail
669 root 1 20 0 16M 5764K select 0:00 0.00% httpd
759 albert 1 20 0 13M 3816K pause 0:00 0.00% tcsh
755 root 1 21 0 20M 9096K select 0:00 0.00% sshd
685 www 1 20 0 16M 5852K lockf 0:00 0.00% httpd
695 root 1 20 0 11M 2620K nanslp 0:00 0.00% cron
684 www 1 20 0 16M 5852K lockf 0:00 0.00% httpd
664 root 1 20 0 19M 7928K select 0:00 0.00% sshd
748 root 1 52 0 11M 2264K ttyin 0:00 0.00% getty
686 www 1 20 0 16M 5644K kqread 0:00 0.00% httpd
747 root 1 52 0 11M 2264K ttyin 0:00 0.00% getty
749 root 1 52 0 11M 2264K ttyin 0:00 0.00% getty
754 root 1 52 0 11M 2264K ttyin 0:00 0.00% getty
751 root 1 52 0 11M 2264K ttyin 0:00 0.00% getty
753 root 1 52 0 11M 2264K ttyin 0:00 0.00% getty
752 root 1 52 0 11M 2264K ttyin 0:00 0.00% getty
750 root 1 52 0 11M 2264K ttyin 0:00 0.00% getty
360 root 1 52 0 11M 2604K select 0:00 0.00% dhclient
363 root 1 52 0 11M 2736K select 0:00 0.00% dhclient
771 www 1 20 0 16M 5776K lockf 0:00 0.00% httpd
691 smmsp 1 52 0 16M 6536K pause 0:00 0.00% sendmail
683 www 1 52 0 16M 5644K lockf 0:00 0.00% httpd
687 www 1 52 0 16M 5644K lockf 0:00 0.00% httpd
409 _dhcp 1 52 0 11M 2856K select 0:00 0.00% dhclient
albert@BSD:~ %
This is all for the successful how to upgrade FreeBSD from 11.2 up to 12.0. There are no error messages in the log, services are up and running, network connections are up and running, so everything looks good. However the article goes on with the rollback section. Just in case something goes wrong and you need a rollback.
6.- Rollback options in case the upgrade wasn’t successful.
Hopefully your upgrade has been good and dandy. But there are occasions this is not the case and solutions must be put into place. And quick.
As mentioned in the beginning of this article systems using ZFS can make use of the boot environments capability unlike the UFS powered ones. Both cases are capable of rolling back, but yet again ZFS happens to be the safer bet and one the reasons and the wet dream of many GNU/Linux administrators. Although they chose to solve this issues by implementing hardware virtualization instead of going to OS level virtualization. What you are going to see is one of the reasons why you should choose FreeBSD over GNU/Linux as I already explained in some other article.
Because we’ve made use of boot environments you must remember we listed them a few times like so.
albert@BSD:~ % sudo beadm list
BE Active Mountpoint Space Created
default - - 62.3M 2018-08-04 23:10
11.2-RELEASE-p2 - - 1.1M 2018-08-19 18:43
11.2-RELEASE-p4 - - 36.5M 2018-10-25 21:04
11.2-RELEASE-p7 - - 55.3M 2018-12-21 21:19
12.0-RELEASE NR / 2.1G 2018-12-21 21:37
albert@BSD:~ %
Now, think of ZFS snapshots. What is a snapshot? A snapshot is a read-only copy of a file system or volume. So when we create a boot environment with beadm what we are doing is creating a snapshot of the current file system and making it available for later use. Because our current environment has been snapshoted, and beadm is clever enough, we can boot back on it. Let’s do this.
We will now set our 11.2-RELEASE-p7 boot environment as the bootable one for the next reboot.
albert@BSD:~ % sudo beadm activate 11.2-RELEASE-p7
Activated successfully
albert@BSD:~ %
We list the available boot environments again and check where the R flag is located this time.
albert@BSD:~ % sudo beadm list
BE Active Mountpoint Space Created
default - - 62.3M 2018-08-04 23:10
11.2-RELEASE-p2 - - 1.1M 2018-08-19 18:43
11.2-RELEASE-p4 - - 36.5M 2018-10-25 21:04
11.2-RELEASE-p7 R - 872.0M 2018-12-21 21:19
12.0-RELEASE N / 1.2G 2018-12-21 21:37
albert@BSD:~ %
As we can see on the next reboot we should get into the 11.2-RELEASE-p7 environment since next to it we can find the ‘R’ flag. Let’s reboot the box and see what happens.
albert@BSD:~ % sudo shutdown -r now
Shutdown NOW!
shutdown: [pid 2090]
albert@BSD:~ %
*** FINAL System shutdown message from albert@BSD ***
System going down IMMEDIATELY
System shutdown time has arrived
We log back in and we check the operating system version.
albert@BSD:~ % uname -mrs
FreeBSD 11.2-RELEASE-p7 amd64
albert@BSD:~ %
I hope you start to sense why is everybody so obssessed into getting ZFS working perfectly on Linux and why is so many people keen to have boot environments soon managed on GNU/Linux land. Just because we’ve just rolled back in a matter of seconds or minutes, depending on your hardware. The company that built this technology originally was called Sun, and I believe they came to the world to give us all light. Use it. It’s awesome.
The 12.0-RELEASE boot environment is still on the system. You can delete it if you wish.
albert@BSD:~ % sudo beadm list
BE Active Mountpoint Space Created
default - - 62.3M 2018-08-04 23:10
11.2-RELEASE-p2 - - 1.1M 2018-08-19 18:43
11.2-RELEASE-p4 - - 36.5M 2018-10-25 21:04
11.2-RELEASE-p6 NR / 872.0M 2018-12-21 21:19
12.0-RELEASE - - 1.2G 2018-12-21 21:37
albert@BSD:~ %
albert@BSD:~ % sudo beadm destroy 12.0-RELEASE
Are you sure you want to destroy '12.0-RELEASE'?
This action cannot be undone (y/[n]): y
Destroyed successfully
albert@BSD:~ %
As you can see the boot environment for 12.0-RELEASE is gone.
albert@BSD:~ % sudo beadm list
BE Active Mountpoint Space Created
default - - 62.3M 2018-08-04 23:10
11.2-RELEASE-p2 - - 1.1M 2018-08-19 18:43
11.2-RELEASE-p4 - - 36.5M 2018-10-25 21:04
11.2-RELEASE-p6 NR / 871.0M 2018-12-21 21:19
albert@BSD:~ %
For those who are still using UFS a rollback is possible. But not as comfortable nor ‘secure’ as the one you’ve been shown just a few lines above. If a rollback on UFS is necessary keep your backups close to you because you may need them quite soon, since rollbacks are fine for minor updates but not between major version upgrades.
We are now on our machine in the 12.0-RELEASE environment and we want to rollback. Let’s do it.
albert@BSD:~ % sudo freebsd-update rollback
src component not installed, skipped
Uninstalling updates...rmdir: ///var/run/dhclient: Directory not empty
done.
albert@BSD:~ %
In principle the updates have been uninstalled so we have to boot back in.
albert@BSD:~ % sudo shutdown -r now
Shutdown NOW!
shutdown: [pid 2090]
albert@BSD:~ %
*** FINAL System shutdown message from albert@BSD ***
System going down IMMEDIATELY
System shutdown time has arrived
We get into the box and we check the OS version, yet again.
albert@BSD:~ % uname -mrs
FreeBSD 11.2-RELEASE-p7 amd64
albert@BSD:~ %
It’s been a successful rollback. Hurray!
Be aware of the binaries issue. You may have to rebuild them again, or install them using the pkg tool. And they may not start back again automatically or conflict with some parts of the system. Test things back as they may not be working anymore. And hey, not all is lost. Next time you may want to use ZFS instead and leverage boot environments, although those running on embedded devices may find the resources toll too high for their use case. In any case ZFS and boot environments can safe the day for you if you administer servers or workstations.
As a UNIX operator and administrator, having worked on production environments with high availability demmands, one knows the real deal backups are as well as rollback operations. Things can work out on development stages and have a nice and smooth period at the integration stage. But for some reason a few times things go unexpectingly wrong. Having these kind of tools like FreeBSD, boot environments, ZFS are precious gold for your projects.
Now, finally, this is all on the how to upgrade FreeBSD from version 11.2 up to 12.0 guide.
Use this link to get 100 $ credit at DOcean and support Adminbyaccident.com hosting costs.