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.
 
Back
Top