Re: symlink to /boot/loader.efi

From: Mark Millard <marklmi_at_yahoo.com>
Date: Fri, 22 Dec 2023 09:09:12 UTC
Tomoaki AOKI <junchoon_at_dec.sakura.ne.jp> wrote on
Date: Thu, 21 Dec 2023 23:21:00 UTC :

> On Thu, 21 Dec 2023 14:22:14 +0100
> Dimitry Andric <dim@FreeBSD.org> wrote:
> 
> > Yeah, my procedure is the same as yours: I first copy /boot/efi/efi/freebsd/loader.efi to /boot/efi/efi/freebsd/loader.old, then copy the freshly built and installed /boot/loader.efi to /boot/efi/efi/freebsd/loader.efi. I don't see a technical reason why this could not be just another step in the installworld procedure.
> > 
> > That said, I am unsure if the pathname /boot/efi/efi is always the same, at least for all UEFI systems. It is the default layout when you do a regular install with recent installer onto a UEFI system, but some users may use completely different mount points. So you should still have some way of configuring the default location for loader installation.
> > 
> > Also, on default installations a fallback entry named /boot/efi/efi/boot/bootx64.efi is made, essentially another copy of loader.efi but with a different name. Namely, the default name that UEFI (on x86_64 at least) searches for, if it doesn't know anything else. I.e. if it isn't configured via efibootmgr(8), or the EFI variables have been junked for some reason. It might make sense to also update that file.
> > 
> > -Dimitry
> 
> Just an idea.
> 
> It would be nice if loader.efi (hopefully, boot1.efi,too) could pass
> "where am I placed?" info, maybe via kenv.
> 
> Would need boot1.efi to pass something (ideally, "where am I booted
> from?", but "boot1_used=1" is sufficient).
> 
> To do so, loader.efi can confirm whether it was loaded via boot1.efi or
> directly from UEFI firmware. If nothing is passed to it, it can probe
> "where it is?" using UEFI call and set it, otherwise, it should
> be /boot/loader.efi, so nothing is needed to do.

To my knowledge aarch64 and armv7 never use the copy in
/boot/loader.efi during a boot. It has to have been copied
into the appropriate msdosfs such that it has an
appropriate path and name there. That is what is found
and used during the boot.

> If no related kenv is set and freebsd-boot partition exists, it should
> be booted with legacy (BIOS) boot.

If there even is a "legacy (BIOS) boot" is a platform
specific issue as far as I know.

> The easiest to be set by loader.efi and/or boot1.efi would be raw UEFI
> device path. So would need analyzing where actually is on booted
> FreeBBSD environment.

See the earlier point about aarch64 and armv7 not using
/boot/* files while loading the FreeBSD loader: the
FreeBSD loader variant used is the first stage able to
look inside UFS or ZFS file systems. Loading and
starting the FreeBSD loader happens before that stage
in those types of contexts.

> . . .

Also, to my knowledge, powerpc (32-bit), powerpc64, and
powerpc64le do not involve any variant of loader.efi or
UEFI/ACPI or UEFI/DeviceTriee in their boot sequnces.
Again: more platform specific rather than generic.

===
Mark Millard
marklmi at yahoo.com