Fixing FreeBSD bootloader after zpool upgrade

This is why I don’t like Mondays. This morning, my FreeBSD laptop denied to boot 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 is kind of like the same situation when you are highly motivated to work, but MS Visual Studio wants to install an update and forces you to take a coffee break for one 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 my ethernet cable at home, about 10,000 km far away.

Luckily, I got this USB stick with DragonFlyBSD installed, 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 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: 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:

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.

Conclusion

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, best 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!