Solved ZFS-on-root with geli won't boot after gpart bootcode

Yesterday, after upgrading to 12.2-RELEASE-p3, I was prompted to zpool upgrade.

After the upgrade, zpool status prompted me to execute a gpart bootcode ... command. Mindlessly, I did gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i1 nvd0. When I rebooted today, I realized that this command had rendered the machine unbootable, which I definitely should have expected. It was so unbootable that the BIOS didn't even recognize the disk anymore.

I tried to repair it from a live USB, but so far have been unable to.
Basically, I did what's described in this post:
gpart bootcode -p /boot/boot1.efifat -i 1 nvd0
gpart bootcode -p /boot/gptzfsboot -i 2 nvd0

The first command has fixed the EFI partition enough that the BIOS at least recognizes that it's bootable again, but it still fails. I also tried dd if=/boot/boot1.efifat of=/dev/nvd0p1, which has not led to different results.

According to gpart show nvd0, I have 4 partitions:
1. efi
2. freebsd-boot
3. freebsd-swap
4. freebsd-zfs

This excludes my second ZFS pool, which is only for storage.

When booting from the live USB, it throughs up this screen:
IMG_6033.jpg

Apparently, it is asking for the passphrase to my geli-encrypted root partition. Inside the shell, I can use geli attach and zpool import to access my pool, it seems to be okay.

When trying to boot from the internal SSD, the screen looks similar, but it says "unable to load /boot/loader.efi" and "no bootable partitions found". This makes sense, since I was never prompted to enter the geli password for my zroot pool, which /boot resides on. Before I broke everything, the geli password prompt would be the first thing to appear when booting.



I'm sure I have missed something somewhere, any help is appreciated.
 
Ok, I have now solved it in probably the worst way possible: I installed the same configuration (EFI+geli+ZFS) on USB drive and used dd to copy over the EFI and freebsd-boot partitions.

If one of you is bored, it'd still be nice to know what happened here and what would have been the proper solution, but my problem is solved. The system boots again and I can finally got to bed.
 
Back
Top