# UEFI or Legacy Boot



## Phishfry (May 26, 2017)

I want to work on my crochet amd64 board file project this weekend. I notice both type boot partitions on the FreeBSD11 memstick installer.
I am trying to figure out the boot process.
I guess the bootloader probes the bios to determine which to use (UEFI or Legacy BIOS)?
I see several different stages to the booatloader.
Which stage picks legacy bios boot or uefi boot?
https://www.freebsd.org/doc/handbook/boot-introduction.html


----------



## Phishfry (May 27, 2017)

So it looks like it is stage 1 with the various boot1 files that picks the boot type? Maybe sooner? Is it BTX server that picks?
boot1
boot1.efi
boot1.efifat


----------



## ANOKNUSA (May 28, 2017)

Phishfry said:


> I guess the bootloader probes the bios to determine which to use (UEFI or Legacy BIOS)?



The board firmware picks which one to load, based either on the boot code it finds at the start of the disk (MBR) or the partition type at the beginning of the disk (GPT). If your board was made in the last five years or so it's either going to  only use UEFI, or it's going to prefer UEFI.


----------



## balanga (May 28, 2017)

Does the UEFI partition have to be the first one on the disk to boot UEFI? And is it just a copy of boot1.efifat?


----------



## tingo (May 28, 2017)

Generally speaking, no the ESP (EFI System Partition) doesn't have to be the first one on the disk. But beware - there are all kinds of bad UEFI implementations out in the wild, some of them are broken.
Second question: yes, if you do a FreeBSD install, the contents of your ESP will be the same as boot1.efifat (warts and all).


----------



## Phishfry (May 28, 2017)

Thanks ANOKNUSA
I was backwards about this... So the board picks the mode. It was right in the manual after all.
That makes sense as I have a malformed UEFI bios on Advantech MIO-2261 and I can manually choose the legacy mode to boot the USB stick from the boards 'boot override' BIOS setting. By default it tries to run UEFI even with CSM enabled. It fails when memstick installer boots UEFI.

An easy indicator for me is the color of the dialog screens for `bsdinstall`. Dark Blue is the legacy color and Light Blue seems to be EFI. Or is it GPT that brings the light blue color to `bsdinstall`? Maybe this is due to vt(4) ? Why is bsdinstaller color different blues? You see my guesses.

The handbook is very well documented for booting. I don't see much about EFI though.


----------

