Re: 24.3. Updating Bootcode

From: Toomas Soome <tsoome_at_me.com>
Date: Tue, 16 Aug 2022 11:10:15 UTC

> On 16. Aug 2022, at 12:49, Nuno Teixeira <eduardo@freebsd.org> wrote:
> 
> Hello all,
> 
> With so much discussion about updating boot, I feel confused about the correct procedure of doing it.
> 
> Like being said there are a "24.3. Updating Bootcode" in Handbook (WIP) that points to some important manuals.
> 
> There are 3 places where boot loader are:
> 
>  ESP (EFI System Partition):
> 1 - (/boot/efi)/efi/boot/bootXXX.efi (default location)
> 2 - (/boot/efi)/efi/freebsd/loader.efi (FreeBSD reserved area)
> Operating System:
> 3 - /boot/loader.efi
> 
> For what I've read we should:
>  - backup: `cp /boot/efi/efi/boot/bootXXX.efi /boot/efi/efi/boot/bootXXX.efi.bkp`
>  - update: `cp /boot/loader.efi /boot/efi/efi/boot/bootXXX.efi`
> 
> In this example we have a /boot/efi mount by the system, "/dev/XXXpN on /boot/efi (msdosfs, local)".
> 
> What about (/boot/efi)/efi/freebsd/loader.efi (reserved area)? Is necessary to backup and update it too?
> 

Hi!

I guess we need to expain a bit. EFI System Partition (ESP from now on, <ESP> for mountpoint), can store both EFI boot programs and EFI applications (diagnostics, firmware update etc). This is the reason, the ESP size is not specified in UEFI specification.

EFI Boot program may be stored on default path <ESP>/efi/boot/bootx64.efi (amd64), <ESP>/efi/boot/bootia32.efi (i386 32-bit), <ESP>/efi/boot/bootaarch64.efi for AARCH64 etc. It is default for case there is no UEFI Boot Manager set up for this media (like installation media on usb stick or cdrom, but also most systems support it with hdd).

Default path obviously does not cope with multi boot setups.

For better OS support, the UEFI specification (UEFI 2.8A Feb 14, page 499) is suggesting to use structure like:

<ESP>/efi/<OS>/…

And to use this suggestion, it means the UEFI Boot Manager needs to be configured (see efibootmgr(8)).

Therefore, once you have set up OS specific setup, there is no use for default (<ESP>/efi/boot/…) and you need to update one or another, but not both.

hope this helps,
toomas