changing ext. USB disk to UEFI boot

From: Matthias Apitz <guru_at_unixarea.de>
Date: Tue, 02 Apr 2024 16:18:40 UTC
I own (for many years) an external USB disk of 1TB to test new FreeBSD
versions on my laptops before installing the system from source to it's
hard disk. This external USB disk boots fine on all my amd64 laptops.

A new acquired ASUS laptop now detects only UEFI boot devices. I'm
attaching below what the FreeBSD's Wiki says and what the current
'gpart list da0' shows about the USB disk.

How can I modify the partition da0p1 to UEFI without touching the already
installed da0p2? Is it enough to carry out the creation of the MS-DOS
file system in da0p1 and copy the boot loader /boot/loader.efi to it?

Thanks


https://wiki.freebsd.org/UEFI

Bootable UEFI memory stick or Hard Disk

To test UEFI booting on a memory stick or a hard disk,
create a GPT partition table with a small EFI partition and the rest
of the space dedicated to a FreeBSD UFS partition:

# gpart create -s gpt da0
# gpart add -t efi -s 40M da0
# gpart add -t freebsd-ufs da0
# newfs_msdos -F 32 -c 1 /dev/da0p1
# mount -t msdosfs /dev/da0p1 /mnt
# mkdir -p /mnt/EFI/BOOT
# cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
# umount /mnt
# newfs -U -L FreeBSD /dev/da0p2
# ...

Current state of the drive da0:

# gpart list da0

Geom name: da0
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 1953525127
first: 40
entries: 128
scheme: GPT
Providers:
1. Name: da0p1
   Mediasize: 524288 (512K)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(1,GPT,a555f52a-90e5-11e9-a3c2-90489a929e43,0x28,0x400)
   rawuuid: a555f52a-90e5-11e9-a3c2-90489a929e43
   rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
   label: extboot
   length: 524288
   offset: 20480
   type: freebsd-boot
   index: 1
   end: 1063
   start: 40
2. Name: da0p2
   Mediasize: 274877906944 (256G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(2,GPT,e1c1853d-90e5-11e9-a3c2-90489a929e43,0x800,0x20000000)
   rawuuid: e1c1853d-90e5-11e9-a3c2-90489a929e43
   rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
   label: extrootfs
   length: 274877906944
   offset: 1048576
   type: freebsd-ufs
   index: 2
   end: 536872959
   start: 2048
3. Name: da0p3
   Mediasize: 2147483648 (2.0G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(3,GPT,0bf60f9c-958a-11e9-8b7f-90489a929e43,0x20000800,0x400000)
   rawuuid: 0bf60f9c-958a-11e9-8b7f-90489a929e43
   rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
   label: extswap
   length: 2147483648
   offset: 274878955520
   type: freebsd-swap
   index: 3
   end: 541067263
   start: 536872960
4. Name: da0p4
   Mediasize: 723177701376 (674G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(4,GPT,1f6fb912-958a-11e9-8b7f-90489a929e43,0x20400800,0x54306000)
   rawuuid: 1f6fb912-958a-11e9-8b7f-90489a929e43
   rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
   label: extbackupfs
   length: 723177701376
   offset: 277026439168
   type: freebsd-ufs
   index: 4
   end: 1953523711
   start: 541067264
Consumers:
1. Name: da0
   Mediasize: 1000204883968 (932G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0


-- 
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub