FreeBSD 8.2 to 9.0 update with ZFS on root (mirror)
Upgrading from one version of FreeBSD to another has become much simpler with
freebsd-update
than before, a full rebuild of the FreeBSD kernel/world
source used to be required (other upgrade paths existed but were not widely
touted). freebsd-update
works extremely well when using UFS as your file
system, there are however some gotcha's that one needs to look out for when
using FreeBSD Root on ZFS. Two machines needed upgrading, both are running with
a ZFS root mirror on FreeBSD 8.2-RELEASE. I had followed the FreeBSD Root on
ZFS (mirror) wiki article and everything has been running smoothly ever
since.
pool: zroot state: ONLINE scrub: scrub completed after 0h35m with 0 errors on Mon Mar 5 10:58:19 2012 config: NAME STATE READ WRITE CKSUM zroot ONLINE 0 0 0 mirror ONLINE 0 0 0 gpt/disk0 ONLINE 0 0 0 gpt/disk1 ONLINE 0 0 0 errors: No known data errors
Wanting to take advantage of some of the advancements made in FreeBSD
9.0-RELEASE such as the updated ZFS, a bug that was fixed that stopped
jails from owning a ZFS file system, improved dtrace, and better IPv6 support
required that the plunge be taken and an upgrade was in order. There were a
couple reports of people having done source upgrades and then having issues
booting their system, but I found one mailling list post that suggested
that everything went well using freebsd-update
, so that is the route I went
with.
I read through the entirety of the FreeBSD 9.0-ERLEASE Release Notes before moving forward to make sure I didn't miss any important changes that would cause my system to not restart correctly or would require changing system configuration files before attempting the upgrade. I would advise you to do the same.
I ran freebsd-update -r 9.0-RELEASE upgrade
and after accepting the list of
components that were installed, I got an error saying:
# freebsd-update -r 9.0-RELEASE upgrade Looking up update.FreeBSD.org mirrors... 4 mirrors found. Fetching metadata signature for 8.2-RELEASE from update2.freebsd.org... done. Fetching metadata index... done. Inspecting system... done. 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/catpages world/dict world/doc world/games world/info world/lib32 world/manpages The following components of FreeBSD do not seem to be installed: world/proflibs Does this look reasonable (y/n)? y Fetching metadata signature for 9.0-RELEASE from update2.freebsd.org... done. Fetching metadata index... done. The update metadata is correctly signed, but failed an integrity check. Cowardly refusing to proceed any further.
Specifically the line stating "Cowardly refusing to proceed further", a quick Google later I found the 9.0-RC1 mailling list post that suggested the following one line fix:
sed -i '' -e 's/=_/=%@_/' /usr/sbin/freebsd-update
After that quick fix, a re-run of freebsd-update
functioned without issues
and finished, showing me what it would change, asking me if it seemed
acceptable and telling me what it was going to remove and what was going to be
installed.
Next we run freebsd-update
for the first time in this three step process:
freebsd-update install
Don't restart yet (although it tells you to)! We need to go back and make sure we update the boot records first.
Going back to the mailling list post made by Magnus Strahlert, I made note of the following:
Had to upgrade the gpt bootcode as instructed when upgrading the zpool for the system to boot.
This is the only comment that worried me, and nowhere in the email thread does the poster describe what commands he ran. In any case I figure he meant re-running the boot code commands from the FreeBSD Root on ZFS wiki article:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da1
After running these commands, it told me that it had updated the boot code and then I ran:
shutdown -r now
After the machine came back online (it is in those moments when you have a small heartattack when the machine doesn't come up as fast as you had expected ...) you log back in and run:
freebsd-update install
This will install all of the updated binaries that came with FreeBSD 9.0, at
this point FreeBSD update will tell you to upgrade all installed software and
ports, and then run freebsd-update
one more time to remove all unnecessary
shared libraries. If you want to have certain software continue functioning,
yet you want freebsd-update
to remove any other remaining old 8.x files, you
can install misc/compat8x
from the ports tree. This is the suggested
route to go if you want to keep the 8.x libraries around for compatibility
reasons.
cd /usr/ports/misc/compat8x make install clean # or # portmaster misc/compat8x
I use portmaster
and the following command will simply rebuild every port
installed on the system:
portmaster -aPf # -P means look for package and if available use it, otherwise build from port
Run freebsd-update
one last time:
freebsd-update install
Since we are running ZFS we will most likely also want to upgrade our pool to the latest version of ZFS to take advantage of any new goodies (such as deduplication!), upgrading a zpool is easy:
zpool upgrade zroot
That upgrades to the latest pool version, now we will want to upgrade our existing file systems to the latest version of ZFS, do note that this will make them incompatible with older file system verisons (so if you use zfs send for backups, your other endpoint will need to be of the same ZFS version)
zfs upgrade # List all ZFS file systems that need to be upgraded zfs upgrade -a # Upgrade all file systems
After this one last reboot to make sure that all the processes come back online using the newer libraries and that you didn't accidentally miss something.
shutdown -r now
At this point the system has been upgraded from FreeBSD 8.0-RELEASE to FreeBSD \9.0-RELEASE and has all of the latest updates and enhancements.