Re: Review D58990: freebsd-update: automatically update EFI and BIOS bootloaders on install
"Ronald Pagani Jr (ronald.pagani.jr)" <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.hackers |
|---|---|
| Message-ID | <CA+aKf4=_PO2pnLuKH_+vtHFVz6UZ9NfAQkDn0UvwGu=nPswMVw@mail.gmail.com> |
On Thu, Aug 20, 2026 at 8:51 AM Mark Millard <[email protected]> wrote: > On 8/20/26 01:08, Ronald Pagani Jr (ronald.pagani.jr) wrote: > > > > > > On Thu, Aug 20, 2026 at 12:37 AM Stefan Esser <[email protected] > > <mailto:[email protected]>> wrote: > > > > 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> <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> <https://github.com/ > > RZA- <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 > > > > > > > > I've just pushed a kern.disks implementation following recent review > > comments, and I'm wondering if that works for you? > > > > https://github.com/RZA-SF/freebsd-patch-for-bug279829/blob/revision-2/ > > src/efi_bootloader_update.sh <https://github.com/RZA-SF/freebsd-patch- > > for-bug279829/blob/revision-2/src/efi_bootloader_update.sh> > > > > > > Best, > > Ron > > > > On an amd64 system it appears it would mount and update every ESP, not > just the booted one. Even the Windows 11 Pro one: > > # gpart show -p nda0 > => 34 3907029101 nda0 GPT (1.8T) > 34 2014 - free - (1007K) > 2048 204800 nda0p1 efi (100M) > 206848 32768 nda0p2 ms-reserved (16M) > 239616 3904946176 nda0p3 ms-basic-data (1.8T) > 3905185792 1843200 nda0p4 ms-recovery (900M) > 3907028992 143 - free - (72K) > > is listed by the --dry-run use. > > This is not appropriate for this system. It has various boot media for > booting various OS's, mostly various FreeBSD versions, some zfs, some > ufs, some rather old. (I select which media/ESP at to boot in the UEFI UI.) > > # sh efi_bootloader_update.sh --dry-run 2>&1 | grep -e Would -e Adding > freebsd-update: [bootloader] INFO: [DRY RUN] Would mount /dev/da1p1 at > /tmp/tmp.upwzASjlJK > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.upwzASjlJK/EFI/FreeBSD/loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.upwzASjlJK/EFI/BOOT/BOOTx64.efi > freebsd-update: [bootloader] INFO: Adding NVRAM boot entry: FreeBSD → > \EFI\FreeBSD\loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would mount /dev/da0p2 at > /tmp/tmp.LwKBxYDbgh > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.LwKBxYDbgh/EFI/FreeBSD/loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.LwKBxYDbgh/EFI/BOOT/BOOTx64.efi > freebsd-update: [bootloader] INFO: Adding NVRAM boot entry: FreeBSD → > \EFI\FreeBSD\loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would mount /dev/nda4p1 at > /tmp/tmp.yJYQH8a2Cz > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.yJYQH8a2Cz/EFI/FreeBSD/loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.yJYQH8a2Cz/EFI/BOOT/BOOTx64.efi > freebsd-update: [bootloader] INFO: Adding NVRAM boot entry: FreeBSD → > \EFI\FreeBSD\loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would mount /dev/nda2p1 at > /tmp/tmp.9MqfM1GtZ9 > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.9MqfM1GtZ9/EFI/FreeBSD/loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.9MqfM1GtZ9/EFI/BOOT/BOOTx64.efi > freebsd-update: [bootloader] INFO: Adding NVRAM boot entry: FreeBSD → > \EFI\FreeBSD\loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would mount /dev/nda1p1 at > /tmp/tmp.xtfvCG9SJQ > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.xtfvCG9SJQ/EFI/FreeBSD/loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.xtfvCG9SJQ/EFI/BOOT/BOOTx64.efi > freebsd-update: [bootloader] INFO: Adding NVRAM boot entry: FreeBSD → > \EFI\FreeBSD\loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would mount /dev/nda0p1 at > /tmp/tmp.oCz0FRiFcZ > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.oCz0FRiFcZ/EFI/FreeBSD/loader.efi > freebsd-update: [bootloader] INFO: [DRY RUN] Would update: > /tmp/tmp.oCz0FRiFcZ/EFI/BOOT/BOOTx64.efi > freebsd-update: [bootloader] INFO: Adding NVRAM boot entry: FreeBSD → > \EFI\FreeBSD\loader.efi > > It did skip media with no ESP: > > => 34 4000797293 nda3 GPT (1.9T) > 34 262144 nda3p1 ms-reserved (128M) > 262178 2014 - free - (1007K) > 264192 3600451584 nda3p2 ms-basic-data (1.7T) > 3600715776 62914560 nda3p3 freebsd-swap (30G) > 3663630336 337166991 - free - (161G) > > > -- > === > Mark Millard > marklmi at yahoo.com Mark, Interesting configuration. I'll take a further look, and update you shortly. Thank You very much for your reports and the feedback you've provided. Best, Ron