How do I boot FreeBSD from GRUB on a UEFI system?

Using Debian on a system with two disks, as an example:

$ cat /etc/grub.d/40_custom 
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "FreeBSD" {
    insmod part_gpt
    insmod chain
    search --fs-uuid --no-floppy --set=root 7D10-E4A0
    search --fs-uuid --no-floppy --set=root 7D0F-1D08
    chainloader ($root)/EFI/freebsd/loader.efi
}

The last part of each search line is the UUID of the ESP, not to be confused with the PARTUUID. Find them with blkid:

$ blkid | grep EFI
/dev/sdb2: LABEL_FATBOOT="EFI" LABEL="EFI" UUID="7D0F-1D08" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="efi1" PARTUUID="02c68f5d-dda6-4207-aab3-92f54966394a"
/dev/sda2: LABEL_FATBOOT="EFI" LABEL="EFI" UUID="7D10-E4A0" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="efi0" PARTUUID="0001a159-991c-4f6a-9ab6-325ab842a49f"

MasonLoringBliss/BootingFreeBSDfromUEFIGRUB (last edited 2022-09-13T20:35:55+0000 by MasonLoringBliss)