FreeBSD: UEFI Bootloader stuck on BootCurrent/BootOrder/BootInfo on Asus Motherboards (and fix!)

Starting with FreeBSD CURRENT from about a few weeks of posting date, but including FreeBSD 12 alpha releases (not related to DEC Alpha), I noticed one thing: When I boot FreeBSD from UEFI on a homebuilt desktop with a Asus H87M-E motherboard, and have Root on ZFS, the bootloader gets stuck on lines like BootCurrent, BootOrder, and BootInfo. This issue occurs when I try to boot directly to efi\boot\bootx64.efi.

One person had a similar issue on a Asus H87I-PLUS motherboard. This issue may or may not exist on other Asus motherboards, desktops, or laptops. This may be specific to Asus motherboards for Intel's Haswell, but may also exist on newer systems (e.g. Skylake) or older (e.g. Ivy Bridge) with Asus motherboards, as well as Asus desktops or laptops.

There are two solutions to this problem:

  1. Use Legacy BIOS mode instead of UEFI mode
  2. Install a FreeBSD UEFI Boot entry

Keep in mind that I am not going to talk about this issue and third-party UEFI boot managers such as rEFInd here.

The first option is rather straightforward: you need to make sure your computer has "Secure Boot" disabled and "Legacy Boot" or "CSM" enabled. Then, you need to make sure FreeBSD is installed in BIOS mode. However, this solution is (in my opinion) suboptimal. Why? Because:

  1. You won't be able to use hard drives bigger than 2TB
  2. You are limited to MBR Partitioning on Asus motherboards with UEFI as Asus motherboards refuse to boot GPT partitioned disks in BIOS mode
  3. Legacy BIOS mode may not exist on future computers or motherboards (although those systems may not have this issue, and this issue may get fixed by then)

The second option, however, is less straightforward, but will let you keep UEFI. Many UEFI systems, including affected Asus motherboards described here, include a boot manager built into the UEFI. FreeBSD includes a tool called efibootmgr to manage this, similar to the similarly-named tool in Linux, but with a different syntax.

So on the system that is stuck on these lines in the bootloader, boot into a FreeBSD CD or USB, and mount the EFI system partition. You can do it from a root shell with:

mount -t msdosfs /dev/ada0p1 /mnt

Where /dev/ada0p1 is the EFI system partition, and /mnt is the directory you want to mount the ESP in. Set these values accordingly if your installation uses something different.

Then, create a UEFI directory for FreeBSD and install boot1.efi by running these commands:

cd /mnt/efi
mkdir FreeBSD
cp /boot/boot1.efi /mnt/efi/FreeBSD

Replace /mnt with the directory you have mounted your ESP in.

After that, you should create the UEFI boot entry for FreeBSD. To do so, run:

efibootmgr -c -l /mnt/efi/FreeBSD/boot1.efi -L FreeBSD

Replace the path /mnt/efi/FreeBSD/boot1.efi with the location where you copied boot1.efi to, and the -L argument to whatever you want to set your UEFI entry to.

Keep in mind that you may be able to point the UEFI boot entry directly to efi\boot\bootx64.efi and skip the previous step, but I have not tested this setup.

After you run efibootmgr, you will get lines such as:

root@megora:~ # efibootmgr
BootCurrent: 0013
Timeout    : 1 seconds
BootOrder  : 0013, 0012, 0014, 0015
 Boot0000  FreeBSD
 Boot0013* Hard Drive 
 Boot0012* CD/DVD Drive 
 Boot0014* UEFI OS
 Boot0015* UEFI OS
root@megora:~ # 

With the number assigned to the FreeBSD entry (for me, 0000), you should set it active. To do so, run:

efibootmgr -a 0000

After you run this, you should get an output like:

root@megora:~ # efibootmgr
BootCurrent: 0013
Timeout    : 1 seconds
BootOrder  : 0000, 0013, 0012, 0014, 0015
 Boot0000* FreeBSD
 Boot0013* Hard Drive 
 Boot0012* CD/DVD Drive 
 Boot0014* UEFI OS
 Boot0015* UEFI OS
root@megora:~ #

If there is a star next to the number for the FreeBSD entry, this means the entry is "active".

Considering that you want FreeBSD as the primary OS, you should check the BootOrder line. If the number assigned to the FreeBSD entry is the first item in BootOrder (like it is with me), you're set. If it's not, change the ordering with something like:

efibootmgr -o "0000, 0013, 0012, 0014, 0015"

Replace the argument of -o with the output from the BootOrder line, modified with the number assigned ordering you want. For instance, you can do it with the number for the FreeBSD entry moved to the first item from where it was for this argument.

You can also set the boot order in the UEFI setup if that's what you prefer.

After you have done these steps, remove the CD or USB, and reboot the system to see if you aren't stuck at lines like BootCurrent, BootOrder, and BootInfo. If you boot into FreeBSD successfully, you're all set!


The idea of using the UEFI boot manager isn't originally mine. It came from Robert Zelaya from FreeBSD's Bugzilla, but his solution used a Linux LiveUSB distro, whereas I use FreeBSD directly.

Show Comments