Solved GPT to UEFI?

Been searching this for a while and finally gave up. Is there a way to take an existing GPT freebsd-boot and replace/convert that partition with a UEFI boot (without destroying/brick the current ufs filesystem it is supposed to boot into)?
 

Do you mean to switch your Boot from BIOS to UEFI? If yes then the best option is to use dump(8) / restore(8) .
Depending of your current partition layout there may be also option to add an ESP. Anyway you still need to make a backup using dump(8) before making any changes to the partitions.
What is your current partition layout? Can you provide the output of gpart show
 
You could remove the freebsd-boot partition and replace it with an efi partition. But this is somewhat risky to do. You're not going to brick the system but it might fail to boot if it's not done correctly. The size should be fine, BOOTx64.efi is only ~460KB and should fit snugly in the 512KB space previously occupied by freebsd-boot.
 
Been searching this for a while and finally gave up. Is there a way to take an existing GPT freebsd-boot and replace/convert that partition with a UEFI boot (without destroying/brick the current ufs filesystem it is supposed to boot into)?
If you have some free space on disk, you can add the UEFI partition with gpart add -t efi -a 4K -i <your efi part #> <your disk>and after that add the UEFI bootcode gpart bootcode -p /boot/boot1.efifat -i <your efi part #> <your disk>. And you will have both methods to boot :cool:

Manual: gpart(8)
 
Note that the efi partition can live anywhere on the disk, it's not required to be the first partition. Only for MBR does it have to be located somewhere in the first 2.someting TB, but this is due to the limitations of MBR. There is no such limitation or requirement with GPT.

Keep a bootable USB stick or CD/DVD at hand though. Just in case you screw up and need it to restore the boot functionality.
 
Wow! That's awesome! I didn't know I could have both. Thank you so much guys! You've been a huge time saver for me. I'll try what Argentum suggested. Very easy and straight forward. If that doesn't work I'll try the suggestion by VladiBG as yes I meant legacy bios to uefi.
 
I didn't know I could have both.
It's even an install option. The nice thing about having both is that you can switch back and forth between EFI and CSM boot.
Code:
dice@chibacity:~ % gpart show
=>       40  625142368  ada0  GPT  (298G)
         40     409600     1  efi  (200M)
     409640       1024     2  freebsd-boot  (512K)
     410664        984        - free -  (492K)
     411648    8388608     3  freebsd-swap  (4.0G)
    8800256  616341504     4  freebsd-zfs  (294G)
  625141760        648        - free -  (324K)

Getting a system to boot with EFI may also require some fiddling with efibootmgr(8). At least I had to with this system. I had to boot the install media and mess around with efibootmgr(8) to get it to recognize the FreeBSD EFI as an option. If you check the machdep.bootmethod sysctl you can tell how the system was booted:
Code:
dice@chibacity:~ % sysctl -a | grep UEFI
machdep.bootmethod: UEFI
Code:
dice@williscorto:~ % sysctl machdep.bootmethod
machdep.bootmethod: BIOS
 
Hi FreeBSD'ers
I had a number of FreeBSD VMs that I first moved from VMWare to KVM/QEMU and then converted all the machines from bios/mbr to UEFI/GPT.

While there are some instructions on how to do "in situ" upgrade based on reusing the 512MB MBR for new GPT bios boot area, this is both fiddly and potentially prone to disaster if something goes wrong.

For both VM (and physical scenario) better way is to use second disk to clone contents over to. Then fix EFI and /etc/fstab details on new disk.

I have documented this in detail including manually mounting the CDROM "/boot/boot.efidat" image, just so people have more understanding of what is going on, behind scene with "gpart boot code ..." example Argentum provided.

See: https://tips.graphica.com.au/converting-freebsd-bios/

If the instructions need correction please let me know.

I have converted over 6 (virtual) machines so far.

Cheers from Oz,

zebity
 
Back
Top