There are two distinct methods you have to use depending on how your system boots. Those are BIOS and UEFI. If you don't know which just type the following command:
sysctl machdep.bootmethod
You will either get UEFI or BIOS.
To update the bootcode for bios you will need to know which volume your boot code is on. To find out run something like the following:
gpart show
You should see an entry like the following:
=> 40 11721045088 ada0 GPT (5.5T)
40 1024 1 freebsd-boot (512K)
1064 4194304 2 freebsd-swap (2.0G)
4195368 11716849760 3 freebsd-zfs (5.5T)
The label "freebsd-boot" is the boot code. The "1" before "freebsd-boot" in this case is the partition, which from my experience is the common partition you will find the BIOS boot loader on. Now you can run the following to install the latest boot loader:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
Where ada0 is this case is the drive, the -i 1 is the partition index. Make sure you get this correct since you could overwrite the data partition, in this case 3.
Once this is done reboot and if it all comes back up correctly you are done.
Note: The FreeBSD handbook has pretty clear instructions on this as well.
To update the bootcode for UEFI you will need to mount the boot partition. If a single drive like a laptop this is quick and easy.
First mount the boot partition.
sudo mount_msdosfs /dev/gpt/efiboot0 /boot/efi
Then copy the new boot loader to the appropriate folder.
sudo cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi
If you have multiple drives in some form of array you will need to do this with all drives that are part of the main boot volume. If this is the case you will need to mount each one and copy the boot loader across. These will be /dev/gpt/efibootx. As in efiboot0, efiboot1 etc.
If you do an ls of the /dev/gpt you should see someting like the following:
efiboot0 efiboot3 efiboot6 efiboot1 efiboot4 efiboot7
efiboot2 efiboot5
In this case you will need to do all eight entries.
Once this is done reboot and if it all comes back up correctly you are done.
Copyright © 2020 | Ben Hutton