Solved How to boot FreeBSD from Linux's GRUB(found it)

It partially works with this, but I have three entries like this that only changes hd0,hd1,hd2. Because it changes every time the PC boots. So I select which one that works at a given time. Sometimes it's hd1 one, or hd2. It changes every damn time. How to make it work every time?

menuentry "FreeBSD ZFS Loader" {
insmod part_gpt
insmod chain
set root='(hd0,gpt1)'
chainloader /EFI/Boot/BOOTX64.EFI
}
menuentry "FreeBSD ZFS Loader" {
insmod part_gpt
insmod chain
set root='(hd1,gpt1)'
chainloader /EFI/Boot/BOOTX64.EFI
}

menuentry "FreeBSD ZFS Loader" {
insmod part_gpt
insmod chain
set root='(hd2,gpt1)'
chainloader /EFI/Boot/BOOTX64.EFI
}
 
Last edited:
Sometimes it's hd1 one, or hd2. It changes every damn time. How to make it work every time?
To avoid disk name order changes interfering with Grub root disk identification use UUIDs to identify the ESP partition.

I don't know a system or port utility on FreeBSD which can provide a partition UUID Grub accepts. On Linux it's lsblk(8). Note: sysutils/lsblk is not the same as Linux lsblk(8).

Boot a Linux distribution (live media or parallel installation), determine ESP UUID, i.e.:
Code:
 $ lsblk -f
NAME   FSTYPE     FSVER LABEL  UUID                FSAVAIL FSUSE% MOUNTPOINTS
loop0  squashfs                                          0   100% /rofs
sda
├─sda1 vfat       FAT16        DFB8-0E1B
├─sda2
└─sda3 zfs_member 5000  zroot  1357010094854037296
Here DFB8-0E1B is the ESP partitions UUID.

Set the UUID in Grub menu with the "search" command:
Code:
menuentry "FreeBSD ZFS Loader" {

       search.fs_uuid  DFB8-0E1B  root
       chainloader  /EFI/Boot/BOOTX64.EFI
}
Side note, the ESP is case insensitive VFAT, upper case, lower case letters don't matter. Alternative settings:
Code:
   chainloader  /efi/boot/bootx64.efi

   chainloader  /efi/freebsd/loader.efi
 
I don't know a system or port utility on FreeBSD which can provide a partition UUID Grub accepts.
Found one: blkid(8), from package sysutils/e2fsprogs-core.

Full format:
Rich (BB code):
% blkid
/dev/ada0p3: TYPE="zfs"
/dev/ada0p1: SEC_TYPE="msdos" UUID="DFB8-0E1B" TYPE="vfat"

List format:
Rich (BB code):
% blkid -o list
device             fs_type   label      mount point            UUID
---------------------------------------------------------------------------------------------------
/dev/ada0p3        zfs                  (not mounted)
/dev/ada0p1        vfat                 (not mounted)          DFB8-0E1B
 
Back
Top