Bug 229191

Summary: efibootmgr(8) fails to create boot var when ESP is mounted using a gpt label
Product: Base System Reporter: Andre Lupa <andrelupa>
Component: binAssignee: Rebecca Cran <bcran>
Status: Open ---    
Severity: Affects Only Me CC: bcran, dch, driesm.michiels, emaste, imp, michael.osipov, ohartmann
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Andre Lupa 2018-06-20 21:45:53 UTC
Consider, for example, the following sequence:

# mount_msdosfs /dev/gpt/efisys /mnt
# mkdir -p /mnt/efi/freebsd
# cp /boot/loader.efi /mnt/efi/freebsd/loader.efi
# efibootmgr -c -l /mnt/efi/freebsd/loader.efi -L FreeBSD
efibootmgr: Cannot translate unix loader path '\mnt\efi\freebsd\loader.efi' to UEFI: No error: 0

If the ESP is mounted using a normal device path (e.g., /dev/ada0p1) then everything works fine.
Comment 1 O. Hartmann 2018-12-27 14:38:17 UTC
Today,  I faced the very same problem on 13-CURRENT, 13.0-CURRENT #43 r342551: Thu Dec 27 14:51:56 CET 2018 amd64.

Mounting ESP via /dev/ada0p1 worked, while mounting via /dev/gpt/efiboot0 does not and did produce the error shown by the initiator of this PR.
Comment 2 Dave Cottlehuber freebsd_committer 2020-11-21 21:00:43 UTC
ditto, on 12.2R and 13.0-CURRENT still obviously.

It's worth noting that the boot var can be created successfully if the underlying msdosfs partition is provided in non-GPT mode:

root@akai /# efibootmgr -c -l nda0p1:/efi/ipxe/netboot.xyz.efi -L iPXE
BootCurrent: 0000
Timeout    : 0 seconds
BootOrder  : 0001, 0000
 Boot0001  iPXE
+Boot0000* efiBoot
root@akai /# mount -t msdosfs -p
/dev/gpt/efiboot	/efi			msdosfs	rw		0 0

root@akai /# efibootmgr -v
BootCurrent: 0000
Timeout    : 0 seconds
BootOrder  : 0001, 0000
 Boot0001  iPXE HD(1,GPT,d16765b3-317d-11e7-ab92-00249b24614a,0x28,0x12c000)/File(\efi\ipxe\netboot.xyz.efi)
                   nda0p1:/efi/ipxe/netboot.xyz.efi (null)
+Boot0000* efiBoot PciRoot(0x0)/Pci(0x1d,0x0)/Pci(0x0,0x0)/NVMe(0x1,d7-ed-0f-00-03-0d-08-00)/HD(1,GPT,d16765b3-317d-11e7-ab92-00249b24614a,0x28,0x12c000)/File(\efi\boot\bootx64.efi)
                      nda0p1:/efi/boot/bootx64.efi (null)
Comment 3 Rebecca Cran freebsd_committer 2020-11-21 21:15:47 UTC
I'm sorry I've not had a chance to work on this. I'm getting back to UEFI work on FreeBSD though, so hope to fix it in the next few weeks.
Comment 4 Warner Losh freebsd_committer 2020-11-22 02:01:11 UTC
The problem here is translating the upper layer GEOM constricts (which is what the GPT label stuff is) to the lower-layer providers. It should be possible to fix that matching code, but I lost patience trying to chase things down w/o hard coding too many things.