So, I bricked my UEFI bootloader after update to
11.2-RELEASE by overwriting
EFI system partition with FreeBSD bootcode 😑, as per the instructions 😉. Thankfully just had to enable BIOS boot, and was able to boot into OS. After that I started looking if there are any instructions to restore, or HOWTO on how to setup FreeBSD with UEFI, and turns out there are plenty of articles available online which show how to boot FreeBSD with UEFI, but apparently they use either rEFInd or some other boot manager, or my search was bad.
I installed this computer using
bsdinstall(8) so I started looking into its sources, and found what I was looking into one of its script.
Make sure your drive (
ada0) is partitioned as below, i.e. atleast has an EFI partition, a boot partition, and ZFS partition:
=> 40 19532873648 ada0 GPT (XXX T) 40 409600 1 efi (200M) 409640 1024 2 freebsd-boot (512K) 410664 984 - free - (492K) 411648 8388608 3 freebsd-swap (4.0G) 8800256 19524071424 4 freebsd-zfs (XXX T) 19532871680 2008 - free - (1.0M)
Setup EFI partition:
# gpart bootcode -p /boot/boot1.efifat -i 1 ada0
# file -s /dev/ada0p1 /dev/ada0p1: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "BSD4.4 ", root entries 512, sectors 1600 (volumes <=32 MB), sectors/FAT 5, sectors/track 63, heads 1, serial number 0xbd4111ee, label: "EFISYS ", FAT (12 bit), followed by FAT
Setup bootcode on FreeBSD boot (
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada0
# shutdown -r now
If you’re running in
RAID1 (or ZFS
mirror mode), make sure to apply this change to other boot drive as well.
That’s it! 😊