I've installed FreeBSD on my MacBook Air, and it runs smoothly. However, instead of appearing with the BSD Daemon icon, it must be booted through a "Fallback boot loader" entry, and I want to change this behavior.

enter image description here

Here is a screenshot I took when booting into FreeBSD through "Boot Fallback boot loader from EFI":

enter image description here

Strangely, I didn't find any file called loader.efi on my device:

sunqingyaos-MacBook-Air:~ sunqingyao$ sudo find / -name "*.efi"
find: /dev/fd/sunqingyao: No such file or directory
find: /dev/fd/sunqingyao: No such file or directory

Still, I tried to target the "Fallback boot loader" by added the following custom entries to /EFI/refind/refind.conf:

menuentry "FreeBSD loader candidate 1" {
    icon \EFI\refind\icons\os_freebsd.png
    loader \EFI\boot\loader.efi

menuentry "FreeBSD loader candidate 2" {
    icon \EFI\refind\icons\os_freebsd.png
    loader \EFI\BOOT\bootx64.efi

But both didn't work. For brevity, I'm only posting the error message for "FreeBSD loader candidate 1":

Starting loader.efi
Using load option ''
Invalid loader file!
Error: Not Found while loading loader.efi

* Hit any key to continue *


The fallback boot loader is EFI/BOOT/bootx64.efi on the EFI System Partition (ESP). The last I checked, this is where FreeBSD stored its boot loader by default. This is a bit strange, and potentially inconsiderate to other OSes -- if every OS used the fallback boot loader filename, they'd all be trampling over each others' boot loaders, much as under BIOS. (One of the advantages of EFI is that it explicitly supports an arbitrarily large number of boot loader files, thus avoiding this problem of BIOS.)

In any event, you have a couple of options:

  • Rename the FreeBSD boot loader or its directory -- If you rename EFI/BOOT on the ESP to EFI/FreeBSD, you should see its icon change in rEFInd. Likewise, if you rename EFI/BOOT/bootx64.efi to EFI/BOOT/freebsd.efi, you should see its icon change. Both of these options have the advantage that some future OS or tool would be able to install its own fallback boot loader without trashing the FreeBSD boot loader; but by the same token, if a FreeBSD package update results in an improved FreeBSD boot loader being installed, it will appear as a new fallback entry in rEFInd, and the entry with the FreeBSD icon in rEFInd will not be updated. You'll neeed to manually copy or rename the new boot loader just as you did the original to apply the update.
  • Apply an icon to the fallback boot loader -- There are quite a few ways to apply icons to the fallback boot loader without renaming or moving it, as described here in the rEFInd documentation. The simplest is likely to be to copy EFI/refind/icons/os_freebsd.png to EFI/BOOT/bootx64.png on the ESP. (That is, to give the icon file the same name as the boot loader itself, but with a .png extension.) Note that this approach will result in a vulnerability: Should something else decide to use the fallback boot loader filename, your FreeBSD installation will become unbootable until you re-install the FreeBSD boot loader. OTOH, updates to the FreeBSD boot loader should apply themselves seamlessly.

Note that both of these options require you to access the ESP. This partition is not mounted by default in OS X, but the mountesp script that comes with rEFInd will mount it, and tell you where it's mounted. I don't know offhand if FreeBSD mounts the ESP by default. If not, you'd need to mount it with the mount_msdosfs command, if I recall the command name correctly. You'd need to provide options to identify the ESP and a mount point.

Creating a manual boot stanza, as you're attempting to do, could also work; but then you'd need to either hide the auto-detected boot loaders or create an entry for OS X, too. Creating a manual boot stanza requires a relatively deep understanding of EFI boot loader files, as well as the syntax for these boot stanzas. It's much easier to rename a boot loader or add an icon file, as I've suggested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.