Other Mirgate from legacy to UEFI boot on physical machine

Hello!

I want to switch from legacy boot to UEFI on installed FreeBSD machine without losing data.
I have such layout:

Code:
 gpart show                                                                                                                                                   4725[0]
=>        40  4000797280  nda0  GPT  (1.9T)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048     4194304     2  freebsd-swap  (2.0G)
     4196352  3996600320     3  freebsd-zfs  (1.9T)
  4000796672         648        - free -  (324K)

Code:
cat /etc/fstab                                                                                                                                          4726[0]
# Device        Mountpoint              FStype  Options         Dump    Pass#
/dev/nda0p2     none                    swap    sw              0       0

I have 1 nvme disk with 3 partitions: boot,swap and main partition with ZFS.

Generaly I need something like what described in this post https://forums.freebsd.org/threads/...f-bootsplash-in-virtual-box.99302/post-719394, but my machine is not virtual so I'n not sure I can do so.

Is it possible to make /boot/efi partition without reinstalling whole system?
I'm on 14.3-RELEASE FreeBSD 14.3-RELEASE releng/14.3-n271432-8c9ce319fef7 GENERIC amd64

P.S. I need it because I can't run my system on Beelinkg S12 PC. Seems like its BIOS has no support for legacy booting.
 
Is it possible to make /boot/efi partition without reinstalling whole system?
You could remove the freebsd-boot partition and create an efi partition in the freed space. Tricky, if it fails to boot you're up shit creek and will need access to a bootable FreeBSD CD/memory stick in order to restore the freebsd-boot partition.

You could also create the efi partition at the end of the disk, it doesn't have to be the first partition, it can be anywhere on disk. But that 324K is probably a bit too small, on 15.0 loader.efi is about 650K and won't fit. You could use boot1.efi instead, but it's a bit of a cludge.

Code:
# ll -h /boot/loader.efi
-r-xr-xr-x  2 root wheel  649K Sep 14 21:03 /boot/loader.efi*
# ll -h /boot/boot1.efi
-r-xr-xr-x  1 root wheel  155K Sep 14 21:03 /boot/boot1.efi*
 
Yes, it works! Thanks a lot again!

For possible future questions here is step by step solution:
Code:
gpart backup nda0
swapoff -a
gpart -i 2 -s 1900M nda0
swapon -a
gpart add -t efi  nda0
newfs_msdos /dev/nda0p4
mount_msdosfs /dev/nda0p4 /media
mkdir -p /media/EFI/BOOT
cp /boot/loader.efi /media/EFI/BOOT/BOOTX64.efi
umount /media

I've also labeled efi partition with gpart modify -i 4 -l gpefiboot nda0, but I'am not sure if it's required.

P.S. Thread can be marked as solved. Thank you!
 
mkdir -p /media/EFI/BOOT
There's an existing /boot/efi mountpoint intended for this.

Add to /etc/fstab:
Code:
/dev/gpt/gpefiboot        /boot/efi       msdosfs rw,noauto       0       0

If you enabled EFI during installation it would have been added to fstab automatically. The installer sets this to always be mounted though, I'm personally not a fan of that. So I have mine set to noauto. This allows me to easily mount it whenever loader.efi needs to be updated; mount /boot/efi
 
There's an existing /boot/efi mountpoint intended for this.

Add to /etc/fstab:
Code:
/dev/gpt/gpefiboot        /boot/efi       msdosfs rw,noauto       0       0

If you enabled EFI during installation it would have been added to fstab automatically. The installer sets this to always be mounted though, I'm personally not a fan of that. So I have mine set to noauto. This allows me to easily mount it whenever loader.efi needs to be updated; mount /boot/efi
Yes, thank you.
I was surprised that my system loaded without mounted /boot/efi partition.
 
I was surprised that my system loaded without mounted /boot/efi partition.
The OS doesn't need anything from it. And to prevent accidental issues I've set it to not be continuously mounted. It only gets mounted temporarily whenever I need to update loader.efi (after a zpool upgrade for example).
 
Back
Top