freebsd-update only updates files under the root filesystem. The EFI System Partition (ESP) is a separate FAT32 partition that the UEFI firmware reads directly. After a major version upgrade, the old loader.efi on the ESP may be incompatible with the new /boot/lua scripts — since 14.1 removed the lua_path==nil compatibility shim in core.lua, this results in a hard boot failure. Running zpool upgrade with a stale ESP loader makes the system completely unbootable.
This patch adds efi_bootloader_update.sh, installed to /usr/libexec/, and hooks it into the install_run phase of freebsd-update. After install_files completes, the script uses boot-scoped ESP discovery: BootCurrent NVRAM identifies the active boot disk; root filesystem disk(s) are determined via zpool status (ZFS) or mount --libxo json (UFS). ZFS vdev names using diskid/gptid paths are resolved to real device names via gpart rawuuid cross-reference. ESP and partition discovery uses gpart show --libxo json throughout with a text-mode fallback for releases where --libxo is unavailable. The union of both sets is used as candidates, ensuring mirror members are all updated while unrelated ESPs (other OSes, other FreeBSD installations) are never touched. A split-media guard restricts candidates to the BootCurrent disk when it does not overlap with the root filesystem disks.
For each candidate ESP the script:
- Mounts it (or reuses an existing mount)
- Updates /EFI/FreeBSD/loader.efi, creating the directory if absent
- Updates /EFI/BOOT/BOOTx64.efi (or arch equivalent) only if it fingerprints as a FreeBSD loader — multi-OS safe. EFI binaries carrying a Secure Boot signature are not overwritten (uefisign -V check, fail-safe, must return 'unsigned' to proceed with update).
- On amd64 14.3+/15.x: copies /boot/loader_ia32.efi to EFI/BOOT/BOOTia32.efi when present, fingerprint-gated. Fresh install (no existing BOOTia32.efi) requires EFI_INSTALL_IA32=1; update of an existing file is unconditional.
- Creates an NVRAM boot entry if none exists, with guards:
- Skips if the fallback binary already fingerprints as FreeBSD
- Skips if efibootmgr returns no parseable BootOrder
- Preserves existing BootOrder entry position Non-fatal if efibootmgr or EFI Runtime Services are unavailable.
- Unmounts the ESP
For BIOS freebsd-boot partitions (scoped to root filesystem disks):
- Writes gptzfsboot or gptboot as appropriate
MBR partition schemes are supported. kern.cam.nda.nvd_compat=1 device aliases (nvd/nda) are resolved via realpath before mount table comparison. Graceful fallback on platforms without EFI Runtime Services. Supports FreeBSD 13.x, 14.x, and 15-CURRENT.
Opt-out: set UpdateBootloader no in /etc/freebsd-update.conf to disable all
bootloader updates. Set UpdateBootloaderNVRAM no to skip NVRAM writes while
still updating ESP files (for fleet environments where NVRAM entries are
managed externally via BMC, Ansible, iDRAC, etc.).
Env override: EFI_NVRAM_UPDATE=0 skips NVRAM for a single invocation.
PR: 279829
See also: D45890 (Warner Losh's complementary loader version-check patch)