Re: UEFI: How to go about updating the ESP with loader.efi during installworld

From: Warner Losh <imp_at_bsdimp.com>
Date: Sun, 4 Nov 2018 16:07:17 -0700
On Sun, Nov 4, 2018 at 2:27 PM Allan Jude <allanjude_at_freebsd.org> wrote:

> On 2018-11-04 16:20, Rebecca Cran wrote:
> > I'm currently working on creating and updating the ESP (EFI System
> Partition)
> > for UEFI booting during installation and installworld.
> >
> > During installation, with my changes it gets mounted on /boot/efi and
> loader.efi
> > copied into /boot/efi/EFI/FreeBSD and /boot/efi/EFI/BOOT. An entry gets
> added to
> > /etc/fstab as noauto.
> >
> > The issue comes during installworld, where we'll need to update the
> loader,
> > and I'm not sure how we should handle that.
> > If NO_ROOT isn't defined, do we just "mount /boot/efi", overwrite the
> files then
> > unmount it? What should we do if NO_ROOT _is_ defined?
> >
>
> Previous to now, installworld has not updated the boot blocks. You've
> had to manually run 'gpart bootcode' to change the boot blocks.
>

That's not true. It always updated /boot/loader.


> However, those boot blocks mostly just loaded /boot/loader, which was
> updated by installworld.
>
> So I can see how this is not directly analogous.
>

I think you're mistaken. I think this is analogous. It used to be that the
boot code was basically unchanging for long periods of time. You can easily
load /boot/loader with a FreeBSD 2 era boot2 (well, off a UFS1 partition).
However, as things are changing more rapidly and as more functionality has
moved into /boot/loader, we need to update it more often. We've moved
support for ZFS into it, support for GELI into it, support for LUA and many
other things. There's no longer any 'boot blocks' at all to update with
gpart. UEFI has eliminated them by moving that functionality into the BIOS
itself.

Other systems update their files in the ESP when they upgrade. This is no
different than that as well. So from an industry perspective, there's a
bias towards updating.


> I wouldn't depend on the /etc/fstab entry existing. I am not sure I want
> installworld randomly fobbing around in my EFI partition. Especially if,
> for example, my EFI/BOOT is not FreeBSD, but rEFInd or something.
>

Yes. It was a huge mistake to *NOT* standardize on this back in the day
when UEFI support came in.

But we'd install it in both places (both /boot/loader*.efi and in
/<WHATEVER>/EFI/FREEBSD/LOADER.EFI), so that would still work with your
rEFInd setup.

Finally, I have a /dev/efi/esp pseudo label support coded up for geom
(along with /dev/efi/boot for the putative root device). There's some
issues with it, so I set it aside some time ago to work on other higher
priority things. We could assume that if there's a filesystem mounted on
/dev/efi/esp, we should update the boot blocks there. We could, by default,
mount it as /efi. A weaker test, though one also in keeping with tradition,
would be to only install into /efi if it's a directory, and it's also a
mount point. that would preserve the status quo and not even need my
/dev/efi/esp code so would work out better from a number of assumptions
point of view.

tl;dr: EFIROOT?=/efi If ${EFIROOT} is a mount point, install loader*.efi
there.

Warner
Received on Sun Nov 04 2018 - 22:07:30 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:19 UTC