Upgrading a FreeBSD system running with ZFS as the root fs
Here’s a summary of the commands I issue when upgrading FreeBSD systems running with ZFS as their root file system.
Update the source tree (assuming the -STABLE branch, currently at 9.0-STABLE, RELENG_9
):
cvsup -g -L 2 /usr/src/stable-supfile
Clear the build tree:
rm -Rf /usr/obj/usr
Recompile everything:
cd /usr/src script -t 0 make-buildworld-buildkernel-yyyymmdd.txt make buildworld buildkernel
Install the new kernel:
script -t 0 make-installkernel-yyyymmdd.txt make installkernel
Reboot into single user mode:
shutdown -r now Upgrade to 9.0-STABLE as of today.; logout
Choose item 4 on the boot loader’s menu. Hit the enter key when asked about which shell to run.
Enable swap, mount the file systems, set the hostname, enable the network interfaces, configure the console for the typical Norwegian user environment, and run an instance of the bash shell:
swapon -a mount -u / zfs mount -a mount -al /etc/netstart /etc/rc.d/syscons start bash
Perform a pre-flight check:
mergemaster -p
Install the newly compiled base OS, commonly known as “world”:
cd /usr/src script -t 0 make-installworld-yyyymmdd.txt make installworld
Merge the current configuration files with the samples found in /usr/src/etc
and elsewhere:
mergemaster -Fi
Remove any obsolete files and directories (note this command is interactive unless there’s nothing to do):
script -t 0 make-delete-old-yyyymmdd.txt make delete-old
Don’t miss this next step or you may be unable to boot your system due to legacy boot blocks not necessarily understand newer spa (pool) and zpl (fs) versions.
Update the boot blocks (assuming GPT and mirrored (S)ATA boot disks):
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
If a new spa version is available, you might want to upgrade your storage pools.
First, check to see if a new spa version is offered by the kernel:
zpool upgrade
Upgrade the storage pools automatically (or at your option manually):
zpool upgrade -a
If a new zpl version is available, you might want to upgrade your file systems.
Check to see if a new zpl version is available:
zfs upgrade
Upgrade the file systems automatically (or at your option manually):
zfs upgrade -a
Cross your fingers and reboot back to the real world:
exit reboot