Solved UEFI boot broken after write gptzfsboot?

Hi All,

After upgrade to 12.2-RELEASE from 12.1-RELEASE, I also upgrade zpool:
Code:
root@T620:/usr/local/vm # zpool upgrade zroot
This system supports ZFS pool feature flags.

Enabled the following features on 'zroot':
  allocation_classes

If you boot from pool 'zroot', don't forget to update boot code.
Assuming you use GPT partitioning and da0 is your boot disk
the following command will do it:

        gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

My zroot is install in ada0, so I run follow command:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0

But after run this command, I recognize that I boot from UEFI, and the efi partition can't mount anymore
Code:
root@T620:/ # mount /dev/ada0p1 /mnt
mount: /dev/ada0p1: No such file or directory

So, I try write boot1.efifat to /dev/ada0p1, but efi partition still can't mount:
Code:
root@T620:/ #  gpart bootcode -p /boot/boot1.efifat -i 1 ada0
partcode written to ada0p1
root@T620:/ # mount /dev/ada0p1 /mnt
mount: /dev/ada0p1: No such file or directory

How could I fix my uefi partition, rebuild fat and copy files?
Thank you.
 
Last edited by a moderator:
What is the result of gpart show ada0?
root@T620:/ # gpart show ada0
=> 40 125033544 ada0 GPT (60G)
40 409600 1 efi (200M)
409640 1024 2 freebsd-boot (512K)
410664 984 - free - (492K)
411648 124620800 3 freebsd-zfs (59G)
125032448 1136 - free - (568K)
 
And output of efibootmgr:
root@T620:/ # efibootmgr
BootCurrent: 0005
Timeout : 0 seconds
BootOrder : 0001, 0002, 0005, 0003, 0004
Boot0001* USB Floppy/CD
Boot0002* USB Hard Drive
+Boot0005* UEFI: FORESEE 64GB SSD
Boot0003* USB Floppy/CD
Boot0004* Hard Drive
 
Dear chk.jxcn,
I have the information below from the FreeBSD questions mailing list.
Two comments are added. You will need a installer disk or stick or so.
I have not done the procedure below by myself.
Code:
In general, if you have EFI partition on your disk, u can use it to store boot loaders.
If u can boot FreeBSD in any way, u can check there :

gpart show

Then mount_msdosfs /dev/adaXpY /anywhere your EFI partition. <<< this should be ada0p1 mounted to /mnt or so
Next you do

mkdir -p /yourEFImountpoint/EFI/freebsd    <<< then yourEFImountpoint should be /mnt
cp /boot/loader.efi /yourEFImountpoint/EFI/freebsd/

Next part is adding your FreeBSD boot loader to your Bios.

efibootmgr -c -L FreeBSD -l /yourEFImountpoint/EFI/freebsd/loader.efi

Reboot system, and hit F12(or any other key) to select boot option
You should see FreeBSD there.
By the way, the update should have been gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada0. I have almost trapped myself, too.
I wish you success!
 
Ok, you should have do: gpart bootcode -p /boot/gptzfsboot -i2 ada0.
You repaired the efi partition, so that's ok. Do you have a problem to boot?

When you use mount without -t option, the file system is UFS by default. So you can't mount an efi partition with such a command. The efi partition is a 'msdosfs' file system. See mount(8).
 
Ok, you should have do: gpart bootcode -p /boot/gptzfsboot -i2 ada0.
You repaired the efi partition, so that's ok. Do you have a problem to boot?

When you use mount without -t option, the file system is UFS by default. So you can't mount an efi partition with such a command. The efi partition is a 'msdosfs' file system. See mount(8).
I have try mount with -t mosdos, and it could be mounted correct, reboot also no issue.
I try mount_msdosfs before write efifat and make sure it not works, but forgot it later.:(
Appreciate it!
 
Dear chk.jxcn,
I have the information below from the FreeBSD questions mailing list.
Two comments are added. You will need a installer disk or stick or so.
I have not done the procedure below by myself.
Code:
In general, if you have EFI partition on your disk, u can use it to store boot loaders.
If u can boot FreeBSD in any way, u can check there :

gpart show

Then mount_msdosfs /dev/adaXpY /anywhere your EFI partition. <<< this should be ada0p1 mounted to /mnt or so
Next you do

mkdir -p /yourEFImountpoint/EFI/freebsd    <<< then yourEFImountpoint should be /mnt
cp /boot/loader.efi /yourEFImountpoint/EFI/freebsd/

Next part is adding your FreeBSD boot loader to your Bios.

efibootmgr -c -L FreeBSD -l /yourEFImountpoint/EFI/freebsd/loader.efi

Reboot system, and hit F12(or any other key) to select boot option
You should see FreeBSD there.
By the way, the update should have been gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada0. I have almost trapped myself, too.
I wish you success!
Thank you, all things works fine now.
BTW, I found /boot/boot1.efifat is a full fat image, so we didn't need copy file anymore:
root@T620:/ # mdconfig -f /boot/boot1.efifat
md0
root@T620:/ # mount_msdosfs /dev/md0 /mnt
root@T620:/ # ls /mnt/efi/boot/
BOOTx64.efi* startup.nsh*
 
Back
Top