Saturday, January 17, 2015

PC-BSD: FreeBSD 10.0 -> 10.1 upgrade using freebsd-update

I was having problems getting pc-sysupdate to work properly. For some reason, purging the pkg cache and forcing updates through pkg update -f resulted in package size mismatches, so I decided to try to upgrade my PC-BSD system manually. It took a while, but I think I figured out how to get it going.

First, I created a boot environment for my new upgrade:

beadm create fbsd_10.1_update
beadm mount fbsd_10.1_update /.updateStage


Next, I performed the freebsd-update on this new boot environment:

freebsd-update -b /.updateStage fetch
freebsd-update -b /.updateStage install


Eventually, the script finished its business. I then switched to the new environment:

beadm umount fbsd_10.1_update
beadm activate fbsd_10.1_update


All done, right? Here's what happened next. I rebooted the machine, and was dropped to a grub> prompt. What? beadm didn't handle grub gracefully?

Ugh. After digging, I figured out how to manhandle grub to boot my ZFS partition. The first trick, to save time, is to set an environment variable to the root filesystem. This saves a LOT of typing. Use "tab" completion to figure out what filesystems are available to you:

set P=(hd0,msdos2)/ROOT/fbsd_10.1_update/@/


Now, we can tell grub to load all the things (tab completion works with the $P expansion! brilliant!):

kfreebsd $P/boot/kernel/kernel
kfreebsd_loadenv $P/boot/device.hints
kfreebsd_module_elf $P/boot/kernel/opensolaris.ko
kfreebsd_module_elf $P/boot/kernel/zfs.ko
kfreebsd_module $P/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
set kFreeBSD.vfs.root.mountfrom=zfs:tank/ROOT/fbsd_10.1_update


boot


Voila! System working again. But I still need to repair GRUB... after the system boots into the correct boot environment:

grub-mkconfig -o /boot/grub/grub.cfg

Unfortunately, that last step didn't actually fix my grub installation. I'm puzzled as to how to fix it. But for now, at least I can get the machine running.

No comments: