Solved [15.0] - How to update boot code after "zpool upgrade -a" (efi)

Hey everyone,

I've performed my regular maintenance tasks on FreeBSD, including the update of my zfs pools:
Code:
zpool upgrade -a

Enabled the following features on 'zroot':
  redaction_list_spill
  raidz_expansion
  fast_dedup
  longname
  large_microzap
  block_cloning_endian
  physical_rewrite

Pool 'zroot' has the bootfs property set, you might need to update
the boot code. See gptzfsboot(8) and loader.efi(8) for details.

ls /boot/efi
gives "efi".

Code:
  pool: zroot
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
nda0p4 ONLINE 0 0 0


If I got this correct, I need to update the boot-loader to ensure compatibility with the new zfs pool features.

I would use the follow commands to do so:
Code:
mount -t msdosfs /dev/gpt/efi /boot/efi
cp /boot/loader.efi /boot/efi/EFI/FreeBSD/loader.efi
cp /boot/loader.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
umount /boot/efi
Is this the correct way to update the boot-code?
 
Assuming the efi partition has that GPT label, yes. It might already be mounted though. And you assume you're UEFI booting, which may or not be the case. You may also have a freebsd-boot partition, you should update that one too, just to keep everything in sync.
 
As to my understanding, it's GPT:

Code:
gpart show

=>       40  488397088  nda0  GPT  (233G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528   67108864     3  freebsd-swap  (32G)
   67643392  420753408     4  freebsd-zfs  (201G)
  488396800        328        - free -  (164K)
Code:
df -h

Filesystem                Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default        190G    4.5G    185G     2%    /
devfs                     1.0K      0B    1.0K     0%    /dev
/dev/gpt/efiboot0         260M    1.3M    259M     1%    /boot/efi
zroot/ROOT/default/nas    185G     96K    185G     0%    /nas
zroot/tmp                 185G     96K    185G     0%    /tmp
zroot/home                185G     96K    185G     0%    /home
zroot/usr/src             185G     96K    185G     0%    /usr/src
zroot                     185G     96K    185G     0%    /zroot
zroot/usr/ports           185G     96K    185G     0%    /usr/ports
zroot/var/log             185G    672K    185G     0%    /var/log
zroot/var/audit           185G     96K    185G     0%    /var/audit
zroot/var/crash           185G     96K    185G     0%    /var/crash
zroot/var/mail            185G    308K    185G     0%    /var/mail
zroot/var/tmp             185G     96K    185G     0%    /var/tmp

Pretty sure it's UEFI booted.

I'm a little confused about "dev/efiboot0" though.
Code:
cp /boot/loader.efi /boot/efi/EFI/FreeBSD/loader.efi
cp /boot/loader.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
Would be correct, if I got this right?


As far as I understand "freebsd-boot" is for legacy (BIOS) booting?
Updating it there would be done with
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 nda0
is this correct?
 
You can use sysutils/loaders-update. You're not obliged to let it update your system (select mode show-me) but all will be clearer and tailored to your system.
Thanks for hinting this tool.

It gave output pretty similar to what I would execute by hand:

loaders-update show-me
loaders-update v1.2.1

One or more efi partition(s) have been found.

Examining nda0p1...
Efi partition nda0p1 is already mounted in /boot/efi.
Would run: cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
Would run: cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi

One or more freebsd-boot partition(s) have been found.
The root file system is zfs.

Examining nda0...
The pmbr on this disk is up-to-date.
Would run: gpart bootcode -p /boot/gptzfsboot -i 2 nda0

-------------------------------
Your current boot method is UEFI.
Boot device: File(\EFI\FREEBSD\LOADER.EFI)
Updatable EFI loader: 2
Updatable BIOS loader: 1
 
It gave output pretty similar to what I would execute by hand:
So, loaders-update is correct. :)

Just an advice: never upgrade a zfs pool "by routine maintenance". And if you have to do such a thing, upgrade your boot loaders BEFORE. Imagine what would have happened if the system unexpectedly shut down just after the pool upgrade...

There is no hurry to upgrade the zfs pools, and to be frank, it's often useless.
 
I recently updated my zfs pools because I was sick of seeing the message :D

When running
Code:
sudo loaders-update show-me
I get similar output to what the OP posted. However, just to be clear, where loaders-update says it would run a command and towards the bottom it says:

Updatable EFI loader: 2
Updatable BIOS loader: 1


Does that mean it has to run the updates despite telling me Efi is already mounted and pmbr is up-to-date, or is it already set? Or is it saying it would run those commands if it wasn't set?


Code:
sudo loaders-update show-me
loaders-update v1.4.0

One or more efi partition(s) have been found.

Examining ada0p1...
Efi partition ada0p1 is already mounted in /boot/efi.
Would run: cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
Would run: cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi

One or more freebsd-boot partition(s) have been found.
The root file system is zfs.

Examining ada0...
The pmbr on this disk is up-to-date.
Would run: gpart bootcode -p /boot/gptzfsboot -i 2 ada0

-------------------------------
Your current boot method is UEFI.
Boot device: Fixed Disk Boot Device 1 PcieRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0,0x0)/HD(1,GPT,2cfaab91-9fbe-11f0-b061-90b11c08ee82,0x28,0x82000)
Updatable EFI loader: 2
Updatable BIOS loader: 1
-------------------------------
 
Run it in shoot-me mode and done. Do not reboot before the loaders are up-to-date if you upgraded your (root) zpool.

Actually, if you are on uefi booting, the freebsd-boot partition doesn't play a role here. That said, it's ok to update it, no problem with that.

Look here if you want more explanations: https://github.com/Emrion/uploaders/blob/main/README.md
Thank you! That worked. For some reason I couldn't find the command to run it, but maybe didn't look hard enough.
 
Thank you! That worked. For some reason I couldn't find the command to run it, but maybe didn't look hard enough.
That's exactly why such a utility is for. If you want to look on what you have to do "by hand", you can. That's not complicated, not to say it's simple.
But, if you have another things to do, you can rely on this software and get your attention on another points.
 
That's exactly why such a utility is for. If you want to look on what you have to do "by hand", you can. That's not complicated, not to say it's simple.
But, if you have another things to do, you can rely on this software and get your attention on another points.
I always try to do commands manually so I understand and learn, but sometimes I really appreciate when people make a pkg to do it all for me. In this case, I love that using the 'show-me' command shows exactly what commands it will run.
 
Back
Top