Fixing broken FreeBSD bootloader after zpool upgrade

This is why I don’t like Mondays. This morning, my FreeBSD laptop denied to boot and complained with the following message:

Consoles: EFI console
ZFS: unsupported feature: com.klarasystems:vdev_zaps_v2
GELI Passphrase for disk1p4: ...

...
ZFS: unsupported feature: com.delphix:head_errlog
ZFS: pool zroot is not supported

This reminded me at a situation at my former work place, where I came highly motivated to work, as usual, but MS Visual Studio first wanted to install an update and forced me into taking a coffee break for the next hour.

Worse, I am here in Kuala Lumpur without access to any other computer that is connected to the internet except my phone. And of course I left the ethernet cable 10,000 km far away at home.

How to fix 10,000 miles away from home

Luckily, I carry around this USB stick with DragonFlyBSD installed on it in my pocket. But unfortunately, it’s WiFi is not configured, and as it needs to download firmware to get it to work, there is no chance to download a FreeBSD memstick image with it. Trying to directly connect to the cable modem fails, too. While “Grab” can delivery any kind of food, they can’t delivery computer accessories. So I end up taking a “Grab” taxi to the next computer store just for buying an USB stick and a flat ethernet cable. Back in my appartment, I plug in the cable to the WiFi router - luckily it has Ethernet ports - and download a FreeBSD 14.0 mini-memstick image and flash that to the newly bought USB stick.

Booting from the FreeBSD mini-memstick image works like a charm! Now I only have to figure out the correct procedure to fix up the messy bootloader. Note that I did a zpool upgrade last night without thinking about possible consequences! Yes, I regret what I did last night :).

The first thing to note is that on FreeBSD 14.0, NVME disk devices are no longer called nvd* but nda* instead. As I am using the EFI boot loader, all I have to do is to copy over the efi bootloader from the memstick to the EFI partition:

mount_msdosfs /dev/nda0p1 /boot/efi
cp /boot/loader.efi /boot/efi/EFI/BOOT/BOOTX64.efi
umount /boot/efi

Note that I could have done this directly from my DragonFlyBSD rescue system as it only involves copying to the EFI partition, which is a MSDOS filesystems.

If you are not using the EFI bootloader, you might have luck with this:

gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 nda0

Note that -i 2 has to point to the freebsd-boot partition which you can figure out using gpart show nda0.

Reminder to myself

Remember: When you travel abroad, always carry a rescue system on an USB stick with you. And if that rescue system doesn’t have WiFi capabilities, add an Ethernet cable to your kit. And to be on the safe side, as ethernet access is rather the exception than the norm, even better is to carry a tiny WiFi router that can act as a repeater and bridge WiFi to Ethernet. I’ve got the GLiNet GL-MT300N but of course left it at home - 10,000 km far away!