Solved GPT to UEFI?

Samuel Venable

Active Member

Reaction score: 133
Messages: 164

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)?
 

VladiBG

Daemon

Reaction score: 571
Messages: 1,248

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,680
Messages: 39,278

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.
 

Argentum

Aspiring Daemon

Reaction score: 296
Messages: 623

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)
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,680
Messages: 39,278

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.
 
OP
Samuel Venable

Samuel Venable

Active Member

Reaction score: 133
Messages: 164

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.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,680
Messages: 39,278

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
 

zebity

New Member

Reaction score: 2
Messages: 9

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
 
Top