# FreeBSD 10.1-STABLE: UEFI booting from USB flash drive



## Juh924 (Dec 25, 2014)

Hello everybody,

I've been trying to make UEFI booting work on my Thinkpad T420. My goal is (as I had previously with BIOS) to boot freebsd from a USB flash drive with my laptop hard drive encrypted.

The T420 is able to boot using UEFI if FreeBSD is installed entirely on the HDD (ada0) or the USB flash drive (da0).

However, when I try to boot from USB and then access the ROOT partition on the HDD, I get the following panic:

```
>> FreeBSD EFI boot block
Loader path: /boot/loader.efi
File /boot/loader.efi not found
panic: Load failed
```
Here are the commands I used (without encryption for the moment):

```
gpart destroy -F ada0
gpart destroy -F da0

gpart create -s gpt ada0
gpart create -s gpt da0
```

Create the EFI and /boot partition on the USB flash drive:

```
gpart add -t efi -a 4K -l bootefi -s 800K da0
gpart add -t freebsd-ufs -l usbboot -s 768M da0
```

Prepare the EFI partition:
`dd if=/boot/boot1.efifat of=/dev/gpt/bootefi`

Partition the HDD. For this example, I will only use one big / partition.
`gpart add -t freebsd-ufs -a 4K -l gprootfs ada0`

Newfs and mount everything:

```
newfs /dev/gpt/usbboot
newfs /dev/gpt/gprootfs

mkdir /tmp/mnt
mount /dev/gpt/gprootfs /tmp/mnt
mkdir /tmp/mnt/boot
mount /dev/gpt/usbboot /tmp/mnt/boot
```

Install FreeBSD:

```
sh
for file in kernel.txz base.txz lib32.txz; do untar --unlink -xpvJf ${file} -C /tmp/mnt done
```

chroot into the new system and create /etc/fstab and /boot/loader.conf


```
chroot /tmp/mnt
echo 'vfs.root.mountfrom="ufs:/dev/gpt/gprootfs"' > boot/loader.conf
echo '/dev/gpt/gprootfs / ufs rw 1 1' > etc/fstab
```

Unmount everything and reboot

```
exit
cd /
umount /tmp/mnt/boot
umount /tmp/mnt

reboot
```

And I get a panic (as shown above)

```
>> FreeBSD EFI boot block
Loader path: /boot/loader.efi
File /boot/loader.efi not found
panic: Load failed
```

Any idea on how to make this work with UEFI? From what I understood, EFI tries to boot on the first ufs partition found. It should be therefore da0p2 ... but it isn't.

Thank you very much.


----------

