Skip to content

Instantly share code, notes, and snippets.

@zeising
Created February 5, 2019 16:49
Show Gist options
  • Save zeising/5d2402d92b4cf421c7402d663b2d9e41 to your computer and use it in GitHub Desktop.
Save zeising/5d2402d92b4cf421c7402d663b2d9e41 to your computer and use it in GitHub Desktop.
rEFInd and FreeBSD
Instructions for installing rEFInd to dual boot a computer with FreeBSD and windows (and possibly other OSes as well).
Note! I use $esp-dev for all commands. Substitude this for the device with your ESP (for example ada0p1)
Download rEFInd from here: http://sourceforge.net/projects/refind/files/0.11.4/refind-bin-0.11.4.zip/download
This gives you a zip-file with everything you need for rEFInd.
Find out which partition is the ESP. This is easiest done by running `gpart list` and look for partitions with `type: efi`.
In a multi-disk setup there might be more than one of those.
I have always installed rEFInd to the one with the Windows bootloader.
To check which one it is, you can mount it using `mount -t msdosfs /dev/$esp-dev /mnt and look in mount.
If EFI/Microsoft exists, then it's most likely the one with the Windows boot loader.
Check the ESP for a FreeBSD loader.
In modern setups it is in EFI/FreeBSD/loader.efi, in older setups it can be located in Boot/bootx64.efi
If you can't find it, create the directory EFI/FreeBSD on the ESP, and copy /boot/loader.efi to that directory.
Check that you have a valid efi boot entry for FreeBSD, run `efibootmgr -v` as root.
If you see something like
+Boot0000* FreeBSD HD(1,GPT,...,...,...)/File(\EFI\freebsd\loader.efi)
$esp-dev:/EFI/freebsd/loader.efi (null)
then everything is OK.
If you don't have this entry, it can be created by
`efibootmgr --create --activate --label FreeBSD --loader $esp-dev:/EFI/FreeBSD/loader.efi`
Double check that this is OK by running `efibootmgr -v` as above.
Once this is done, extract the rEFInd zip file somewhere on the file system.
On the ESP device, create the directory EFI/rEFInd.
Copy the contents of refind-bin-$version/refind (which is what you extracted) to EFI/rEFInd.
Create a efi boot entry for rEFInd.
`efibootmgr --create --activate --label rEFInd --loader $esp-dev:/EFI/rEFInd/refind_x64.efi`
Refind has a configuration file, EFI/rEFInd/refind.conf-sample, which can be copied to refind.conf and edited.
In the default set up, this should not be needed though.
Reboot the system, and configure your UEFI firmware to boot to the rEFInd loader first.
This loader should detect all your efi boot loader, and give you a menu where you select which one to boot.
It is also possible to add entries manually by editing refind.conf.
I have had trouble sometimes when the FreeBSD loader can't find the kernel, if the loader and the kernel are on different hard drives.
Try to add the FreeBSD loader to the same hard drive that has the kernel, if you have trouble booting.
If this happens, you'll see the loader start, and then complain about being unable to find the kernel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment