Re: bootcode update after zpool upgrade

From: Miroslav Lachman <000.fbsd_at_quip.cz>
Date: Thu, 24 Feb 2022 18:51:13 UTC
On 24/02/2022 17:55, Warner Losh wrote:
> 
> 
> On Thu, Feb 24, 2022 at 4:49 AM Miroslav Lachman <000.fbsd@quip.cz 
> <mailto:000.fbsd@quip.cz>> wrote:
> 
>     On 24/02/2022 10:43, Alexander Leidinger wrote:
>      > Quoting Miroslav Lachman <000.fbsd@quip.cz
>     <mailto:000.fbsd@quip.cz>> (from Wed, 23 Feb 2022
> 
>      >> I am not sure what I should update. This machine is EFI boot only
>      >> (this is the only one EFI machine we have).
>      >
>      >> Should I run:
>      >> gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 nvd0
>      >> gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 nvd1
>      >
>      > This is the bootcode zpool upgrade talks about.
>      >
>      >> Or should I update EFI partitions? (if so, then how?)
>      >
>      > The EFI partition contains the loader, not the bootcode.
>      >
>      > While we are at it, I'm still looking for the place where I can find
>      > which features the bootcode supports. Not all features are
>     supported for
>      > a root pool.
> 
>     Thank you for the clarification!
> 
> 
> If you've updated your ZFS pool and have an old system, you do need to 
> update
> the EFI boot code. None of the mbr stuff is used for EFI booting.
> 
> If you have an old installation, it may be small. So ideally, you'd copy 
> over /boot/loader.efi
> to ESP:efi/boot/bootx64.efi. However, it may be too big if you have an 
> ESP created by the
> old installer. In that case, you'll need to either create a new, larger 
> ESP, or copying /boot/boot1.efi
> instead.

This machine was installed 2 years ago as FreeBSD 11.2 and then upgraded 
to 11.4 and 12.2. The last update was from 12.2-p9 to 12.2-p13 so the 
machine was booting fine without modification of bootcode and with 
FreeBSD 12.2-p9 but after the last update to -p13 I decided to run 
"zpool upgrade".

So the question is, do I need to update efi/boot/bootx64.efi?

I tried to look at it:

# mount -t msdosfs /dev/nvd0p1 /media/

# ll /media/efi/boot/
total 385
-rwxr-xr-x  1 root  wheel   384K Apr 16  2018 BOOTx64.efi*
-rwxr-xr-x  1 root  wheel    12B Apr 16  2018 startup.nsh*

The BOOTx64.efi is old, from 11.2 install.

The newer one in /boot/ looks bigger

478K Mar 24  2021 loader.efi


And the second question is back on bootcode. I already run gpart bootcode:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 nvd0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 nvd1

But I found something in my notes from install time few years ago:
gpart bootcode -p /boot/boot1.efifat -i 2 /dev/nvd01

What really should be installed on freebsd-boot partition?
/boot/gptzfsboot or /boot/boot1.efifat

# gpart show
=>        40  1953525088  nvd0  GPT  (932G)
           40      409600     1  efi  (200M)
       409640        1024     2  freebsd-boot  (512K)
       410664      113624        - free -  (55M)
       524288    20971520     3  freebsd-swap  (10G)
     21495808  1932001280     4  freebsd-zfs  (921G)
   1953497088       28040        - free -  (14M)

I am sorry for asking this questions but this is the only machine with 
EFI I had and never did "zpool upgrade" on it.

Is there a way to test if the machine will be bootable befor I try to 
reboot it? The machine is not physically accessible to me so the 
recovery from failed boot is very problematic.

Kind regards
Miroslav Lachman