# zpool upgrade change bootcode (RESOLVED)



## maremar (Feb 6, 2022)

Hi,

 We've done a zpool upgrade but we have a question:

  Should we do a  `gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0` or a `gpart bootcode -p /boot/boot1.efifat -i 1 ada0` on both disks to do a correct boot upgrade?












Many thanks


----------



## chrbr (Feb 6, 2022)

Regarding the first command it should be `-i 2` because this is where freebsd-boot resides. Without EFI it is most likely `-i 1`. The examples you can find with a search engine often come from the pre-EFI times. About the second command `-i 1` should be ok. But I am not sure if this is necessary.

Please check the meaning of the parameter i in gpart(8) and wait for an advise regarding the second command before updating the boot code and the EFI stuff. I am just a hobbyist .

EDIT: removed the = between i and the number and added a - because this is how it ends up in the command.


----------



## Emrion (Feb 6, 2022)

Yes, it's `-i 2` for the the `gpart bootcode` command in your case. See here for the whole thing.


----------



## maremar (Feb 6, 2022)

If I've understood, to upgrade correctly bootcode in my zfs mirror:

first:
#gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot* -i 2* ada0
#gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot *-i 2* ada1

Second:
#gpart bootcode -p /boot/boot1.efifat *-i 1* ada0
#gpart bootcode -p /boot/boot1.efifat *-i 1* ada1

am I right?

PS: Second pass is mandatory? <-- It's deprecated, don't do it

Thanks again to all


----------



## grahamperrin@ (Feb 6, 2022)

maremar said:


> am I right?



Is it UEFI boot?


----------



## maremar (Feb 6, 2022)

I think it is , isn't it?


----------



## zirias@ (Feb 6, 2022)

maremar said:


> gpart bootcode -p /boot/boot1.efifat *-i 1* ada0


Don't do that, boot1.efifat is deprecated (IIRC removed on FreeBSD 13).

Mount your EFI partition and copy /boot/loader.efi over EFI/BOOT/BOOTx64.efi instead.



maremar said:


> PS: Second pass is mandatory?


Your partitions support both UEFI and CSM boot. Best update both bootloaders. You can learn which method you are currently using with `sysctl machdep.bootmethod`, but anyways it doesn't hurt to have both bootloaders up to date.


----------



## Emrion (Feb 6, 2022)

maremar said:


> Second:
> #gpart bootcode -p /boot/boot1.efifat *-i 1* ada0
> #gpart bootcode -p /boot/boot1.efifat *-i 1* ada1


No. Read my howto. This is the old method.

Update both UEFI and Bios bootcodes.


----------



## maremar (Feb 6, 2022)

I didn't know how to find it out, thanks again

root@crucoli:~ # *sysctl machdep.bootmethod*
machdep.bootmethod: UEFI

Thanks to all, specialy to Emrion (and his manual) and Zirias. I've doing some tests with a spare machine and I think I have understand something I didn't have very clear:

GPT table, BIOS boot only






GPT Table, UEFI boot only






GPT Table, UEFI and BIOS boot







Thanks again and happy sunday to everybody


----------

