Re: 24.3. Updating Bootcode

From: Warner Losh <imp_at_bsdimp.com>
Date: Tue, 16 Aug 2022 17:15:19 UTC
On Tue, Aug 16, 2022 at 3:49 AM 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)
>

Default for the boot loader, that is. By default we don't install here
anymore (though as a workaround
for broken BIOSes or those that don't properly save EFI env vars or that
change help to be helpful,
we'll park a copy here, this usually isn't updated).


> 2 - (/boot/efi)/efi/freebsd/loader.efi (FreeBSD reserved area)
>

This is what the boot usually uses on working systems.


> Operating System:
> 3 - /boot/loader.efi
>

This is only used when chain loaded from a legacy system that installed
boot1.efi, or in some cases
from a 'special needs' system that loads it from gptboot.efi.


> For what I've read we should:
>  - backup: `cp /boot/efi/efi/boot/bootXXX.efi
> /boot/efi/efi/boot/bootXXX.efi.bkp`
>

I'd recommend bootXXX-old.efi (or bootXXX-bkp.efi) since you'll be able to
run it from the EFI shell
if you are lucky enough to have one. The shell won't run the .bkp file.


>  - update: `cp /boot/loader.efi /boot/efi/efi/boot/bootXXX.efi`
>

Yes and no. You should likely update both this one and the one in
efi/freebsd as well since the latter
is more typically used (though your system may be one of the
sadly-too-sizable number of systems
that ignore the env vars and use the default removable media file).


> In this example we have a /boot/efi mount by the system, "/dev/XXXpN on
> /boot/efi (msdosfs, local)".
>

Yes.


> What about (/boot/efi)/efi/freebsd/loader.efi (reserved area)? Is
> necessary to backup and update it too?
>

It's the primary thing that gets used most of the time. I'd certainly back
it up and update it.

Warner