Re: Review D58990: freebsd-update: automatically update EFI and BIOS bootloaders on install

Stefan Esser <[email protected]>
Newsgroups gmane.os.freebsd.devel.hackers
Message-ID <[email protected]>
Am 19.08.26 um 18:30 schrieb Ronald Pagani Jr (ronald.pagani.jr):
> I've submitted a patch to automatically update the EFI bootloader on the ESP 
> during freebsd-update install:
> 
> https://reviews.freebsd.org/D58990 <https://reviews.freebsd.org/D58990>
> 
> The problem: freebsd-update updates /boot/loader.efi on the root filesystem, 
> but the UEFI firmware boots from loader.efi on the EFI System Partition — a 
> separate FAT32 partition that freebsd-update never touches. After a major 
> version upgrade the ESP loader can be left several versions stale. Since 14.1 
> removed the lua_path==nil compatibility shim from core.lua, this mismatch 
> produces a hard boot failure. If the user also ran zpool upgrade, the system is 
> completely unbootable without external media.
> 
> The patch hooks efi_bootloader_update.sh into install_run() in freebsd- 
> update.sh. It auto-detects the ESP via gpart, fingerprints /EFI/BOOT/ 
> BOOTx64.efi before touching it (multi-OS safe), creates /EFI/FreeBSD/loader.efi 
> if absent, updates NVRAM, and handles BIOS GPT bootcode as well. Opt-out via 
> UpdateBootloader=no in freebsd-update.conf.
> 
> Tested on FreeBSD 14.0-RELEASE-p11 amd64 (UEFI, ZFS, NVMe). 197 unit/ 
> integration/error tests available at:
> 
> https://github.com/RZA-SF/freebsd-patch-for-bug279829 <https://github.com/RZA- 
> SF/freebsd-patch-for-bug279829>

I'm using a much simpler version that just covers my setup, and would
like to replace it by a more general version.

This fails for me in lines 231 to 236 since device names are expected,
but zpool status returns a diskid based path:

$ zpool status zroot
   pool: zroot
  state: ONLINE
config:

	NAME                          STATE     READ WRITE CKSUM
	zroot                         ONLINE       0     0     0
	  diskid/DISK-8ESKF03YZ0EAp2  ONLINE       0     0     0

errors: No known data errors

$ sh efi_bootloader_update.sh --dry-run
freebsd-update: [bootloader] INFO:  Boot method detected: UEFI
freebsd-update: [bootloader] WARN:  No boot disks found
freebsd-update: [bootloader] WARN:  Boot disk discovery failed
freebsd-update: [bootloader] WARN:  If using hardware RAID or an exotic 
topology, update the bootloader manually

My version uses "gpart show -p" to list boot partitions and to fetch
the corresponding device names:

$ gpart show -p | grep -w efi
         2048      522240  diskid/DISK-8ESKF03YZ0EAp1  efi  (255M)
         2048      522240  diskid/DISK-81S0A0K7FJDHp1  efi  (255M)
         2048      522240  diskid/DISK-81S0A0L1FJDHp1  efi  (255M)

> This is complementary to Warner Losh's D45890 (loader version-check warnings). 
> Feedback welcome.
Regards
STefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.