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). 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
- Creates an NVRAM boot entry if none exists (non-fatal if 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. Graceful fallback on platforms
without EFI Runtime Services.
Opt-out: set UpdateBootloader=no in /etc/freebsd-update.conf.
Env override: EFI_NVRAM_UPDATE=0 skips NVRAM writes.
PR: 279829
See also: D45890 (Warner Losh's complementary loader version-check patch)