# UEFI boot FAIL!



## verus (Apr 3, 2015)

Howdy All,

I have been beating my head against the brick wall that is this issue for the last few days. I have tried everything I can think of and everything I have found on this forum and others. I will explain my goal and what I have attempted.

Also this is the first time I am trying to install FreeBSD on an UEFI system

Goal:
Dual boot FreeBSD 10.1 and Windows 8.1 (required for work)
Boot manager: don't really care rEFInd, Grub2, ect
I am installing FreeBSD 10.1 using the FreeBSD-10.1-RELEASE-amd64-uefi-memstick.img .
I am installing this on Asus X200MA-RCLT08

First installation attempt:
windows 8.1 working boots normally
Disabled secure boot
installed from usb and used UFS (GTP)
partition talble is:
100MB EFI -(windows UEFI)
900MB Recovery
128MB MS- Reserverd
186GB MS-basic-data
800KB  EFI (FreeBSD)
144GB FreeBSD-UFS /
4GB FreeBSD-swap

Issue:
FreeBSD will not freaking boot!!!
UEFI dose not see the EFI partition created during installation. 
It will boot if the install media is in the USB port it was in during installation and that is selected from the UEFI boot menu. (note if it is not in the USB port used during install, then the installation menu is booted)

Attempted resolutions:

I followed this guide http://ximalas.info/2015/03/19/uefi-gpt-windows-10-freebsd-10-and-refind/
when I select freeBSD from the menu I get the attached error 

```
Fatal trap 1 with interrupts dissabled

Fatal trap 1: privileged instruction fault while in kernel mode
cpuid = 0; apic id = 00
instruction pointer     = 0x20:0xffffff80400000
stack pointer           = 0x28:0xffffff814b5a70
frame pointer           = 0x28:0x0
code segment            = base 0x0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags        = resume, IOPL = 0
current process         = 0 ()
trap number             = 1
panic: privileged instruction fault
cpuid = 0
KDB: stack backtrace:
#0 0xffffffff80963000 at ??+0
#1 0xffffffff80928125 at ??+0
#2 0xffffffff80d24f1f at ??+0
#3 0xffffffff80d24b7c at ??+0
#4 0xffffffff80d0a782 at ??+0
Uptime: 1s
```
 I then attempted to skip the 3rd party boot loader and mounted the windows ESP again and copied the /boot/boot1.efi to /esp/efi/fbsd/bootx64.efi
I then in the system UEFI created boot entry pointing at /efi/fbsd/bootx64.efi 
booted the system to the new entry and 

```
Fatal trap 1 with interrupts dissabled

Fatal trap 1: privileged instruction fault while in kernel mode
cpuid = 0; apic id = 00
instruction pointer     = 0x20:0xffffff80400000
stack pointer           = 0x28:0xffffff814b5a70
frame pointer           = 0x28:0x0
code segment            = base 0x0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags        = resume, IOPL = 0
current process         = 0 ()
trap number             = 1
panic: privileged instruction fault
cpuid = 0
KDB: stack backtrace:
#0 0xffffffff80963000 at ??+0
#1 0xffffffff80928125 at ??+0
#2 0xffffffff80d24f1f at ??+0
#3 0xffffffff80d24b7c at ??+0
#4 0xffffffff80d0a782 at ??+0
Uptime: 1s
```
Again!!!

Second installation attempt:
Disabled secure boot
installed from usb and used UFS (GTP)
partition talble is:
800KB  EFI (FreeBSD)
144GB FreeBSD-UFS /
4GB FreeBSD-swap

UEFI Sees the EFI Partition now: YAY (im hopeful; who needs wendooz anyway)
I boot the system and ... wait for it....

```
Fatal trap 1 with interrupts dissabled

Fatal trap 1: privileged instruction fault while in kernel mode
cpuid = 0; apic id = 00
instruction pointer     = 0x20:0xffffff80400000
stack pointer           = 0x28:0xffffff814b5a70
frame pointer           = 0x28:0x0
code segment            = base 0x0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags        = resume, IOPL = 0
current process         = 0 ()
trap number             = 1
panic: privileged instruction fault
cpuid = 0
KDB: stack backtrace:
#0 0xffffffff80963000 at ??+0
#1 0xffffffff80928125 at ??+0
#2 0xffffffff80d24f1f at ??+0
#3 0xffffffff80d24b7c at ??+0
#4 0xffffffff80d0a782 at ??+0
Uptime: 1s
```

FML


----------



## fernandel (Apr 3, 2015)

I don't know if will help you but...
When I installed FreeBSD on iMac 11,1 I used rEFInd and I had a problems with "fatal trap". Than I use the http://refit.sourceforge.net/ and it works like a charm .


----------



## verus (Apr 3, 2015)

fernandel said:


> I don't know if will help you but...
> When I installed FreeBSD on iMac 11,1 I used rEFInd and I had a problems with "fatal trap". Than I use the http://refit.sourceforge.net/ and it works like a charm .



Thanks fernandel I'll give it a try.


----------



## verus (Apr 4, 2015)

sadly no joy looks like the same issue.


----------



## trev (Apr 5, 2015)

Similar issues (fatal traps) installing any version of FreeBSD after 9.1-Release (on a Mac Mini - late 2009), so I installed 9.1 and then compiled 10.1 from source which worked  I don't know if it will help in your situation, but you could always give it a go. 

Full details at https://forums.freebsd.org/threads/mac-mini-3-1-installer-failure-9-3-10-1.51046/


----------



## verus (Apr 5, 2015)

Trev, Thank you for your suggestion I'll take a look.


----------



## verus (Apr 5, 2015)

FYI: sadly the UEFI implementation on this laptop does not seem to support MBR partitions  so I am stuck trying to solve this


----------



## fernandel (Apr 5, 2015)

https://glenbarber.us/2011/11/12/Dual-Booting-OS-X-and-FreeBSD-9.html

Above link help me too.


----------



## verus (Apr 5, 2015)

Howdy all tried the suggestions above. Still no joy.

I also tried `dd if=/boot/boot1.efifat of=/dev/ada0p1` to rewrite the EFI partition. I guess what is bugging me most is that booting from usb using UEFI isn't an issue, and I don't understand why the internal HDD would be any different.


----------



## trev (Apr 6, 2015)

verus said:


> FYI: sadly the UEFI implementation on this laptop does not seem to support MBR partitions  so I am stuck trying to solve this



Forget MBR partitions then, use GPT which is what I ended up with on the Mac Mini:

`gpart show`

```
=>  34  976773101  ada0  GPT  (466G)
  34  128  1  freebsd-boot  (64K)
  162  4194304  2  freebsd-ufs  (2.0G)
  4194466  41943040  3  freebsd-ufs  (20G)
  46137506  83886080  4  freebsd-ufs  (40G)
  130023586  83886080  5  freebsd-ufs  (40G)
  213909666  41943040  6  freebsd-ufs  (20G)
  255852706  419430400  7  freebsd-ufs  (200G)
  675283106  281018368  8  freebsd-ufs  (134G)
  956301474  18874368  9  freebsd-swap  (9.0G)
  975175842  1597293  - free -  (780M)
```


----------



## verus (Apr 6, 2015)

trev said:


> Forget MBR partitions then, use GPT which is what I ended up with on the Mac Mini:
> 
> `gpart show`
> 
> ...




I had tried to use the non UEFI image to install and point the bios in legacy mode to the MBR but it does not show as an option Asus doesn't support MBR on the newer boards.


----------



## trev (Apr 6, 2015)

verus said:


> I had tried to use the non UEFI image to install and point the bios in legacy mode to the MBR but it does not show as an option Asus doesn't support MBR on the newer boards.



Ignore MBR, the FreeBSD installer defaults to GPT (at least with 9.1-R), it can also be changed in the installer  before you partition.


----------



## verus (Apr 6, 2015)

trev said:


> Ignore MBR, the FreeBSD installer defaults to GPT (at least with 9.1-R), it can also be changed in the installer  before you partition.



Thank you. I was just trying to get BSD to boot with out the boot loader being on USB.


----------



## georges (Apr 6, 2015)

I had similar but not booting from one drive. Maybe it will help.


I have 2 internal HDD and like you my ASUS motherboard only supports UEFI booting. No legacy.
FreeBSD 10+ installs fine but never able to boot on my 2nd HDD.

After a lot of banging and coffee, I did the following:

Install and then drop to a shell before exiting the installation or reboot from the CD, drop to emergency shell and did the following:


```
gpart set -a active <drive/partition>
```

This worked every time. I have to do this every time I install. Even PC-BSD have the same problem.

Hope this helps.


----------



## verus (Apr 6, 2015)

Which partition are you setting to active?

BTW I think I read your post on here.


----------



## georges (Apr 6, 2015)

In my case I installed FreeBSD with auto ZFS, then I set active on the whole drive. My drive is ada1. So I did:
`gpart set -a active /dev/ada1`

Worked everytime. If you _are_ installing to a partition (as sharing one drive with Windows) I'll probably set it on that partitions.
`gpart list`
or
`gpart show`

It will show the boot partition I think.

Will show all the info.


----------



## verus (Apr 6, 2015)

My partition table is as below:
`gpart show`

```
800KB EFI (FreeBSD)
144GB FreeBSD-UFS /
4GB FreeBSD-swap
```

So I ran
`gpart set -a active /dev/ada0`

Now the bios does not see the drive.


----------



## georges (Apr 6, 2015)

Mine shows the following

`gpart show ada1`

```
=>  34  1465149101  ada1  GPT  (699G)
  34  1024  1  freebsd-boot  (512K)
  1058  4194304  2  freebsd-swap  (2.0G)
  4195362  1460953773  3  freebsd-zfs  (697G)
```

So I set it to the whole disk.  I chose at installation the 2nd drive and told it not to install the boot record record on the 1st as I don't want to dual boot(I just boot through boot menu). Probably that is what is different.


----------



## verus (Apr 6, 2015)

getopt said:


> The freebsd-boot partition is missing and you miss-leaded the BIOS looking into a geom without one. That is why the BIOS cannot find anything.
> 
> You probably need to boot with i.e. an USB medium and do the partitioning on the hard drive from the fixit shell if your first hard drive cannot boot or has no tools.



I used the Auto (UFS) option during install and that is what it gives me. Please correct me if i am wrong but isn't the 144GB partition (since it is set as root (/)) the boot partition? what would you recommend as a solution?


----------



## wblock@ (Apr 6, 2015)

verus said:


> Asus doesn't support MBR on the newer boards



Really?  Or does it just not appear until SecureBoot is disabled?


----------



## verus (Apr 6, 2015)

wblock@ said:


> Really?  Or does it just not appear until SecureBoot is disabled?


There is NO legacy support for hard drives or SSD even with secureboot disabled. On the new Asus boards disabling secureboot just doesn't enforce signing, or so I was told by Asus support.


----------



## wblock@ (Apr 6, 2015)

Wow, yet another reason to avoid Asus.


----------



## verus (Apr 6, 2015)

wblock@ said:


> Wow, yet another reason to avoid Asus.


I had always had good luck, what is your preference? Just out of curiosity?

If I can't get this working on this NetBook then I will be looking for another small EDC laptop.


----------



## chrbr (Apr 6, 2015)

verus said:


> I used the Auto (UFS) option during install and that is what it gives me.


Please see figure 2.15 in https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/bsdinstall-partitioning.html. It shows a freebsd-boot partition where the software to start up FreeBSD is copied to during installation. See gpart(8) section bootcode. Information about the booting is in gptbootcode(8) and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/boot-introduction.html.

Regarding the installation, please try the auto setup again, just to be sure . If it does not work follow http://www.wonkity.com/~wblock/docs/html/disksetup.html. I think it is more clear than the ncurses dialog of the manual installer. Thank you wblock@ . You can decide if you like to have mount points for /usr, /var and /tmp or if you just want everything under the root partition. For the beginning, just to test if you can finally startup I would suggest to have it as simple as possible. I just hope that there are any additional restrictions due to ASUS. Good luck!


----------



## verus (Apr 6, 2015)

chrbr said:


> Please see figure 2.15 in https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/bsdinstall-partitioning.html. It shows a freebsd-boot partition where the software to startup FreeBSD is copied to during installation. See gpart(8) section bootcode. Information about the booting is in gptbootcode(8) and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/boot-introduction.html.
> 
> Regarding the installation, please try the auto setup again, just to be sure . If it does not work follow http://www.wonkity.com/~wblock/docs/html/disksetup.html. I think it is more clear than the ncurses dialog of the manual installer. Thank you wblock@ . You can decide if you like to have mount points for /usr, /var and /tmp or if you just want everything under the root partition. For the beginning, just to test if you can finally startup I would suggest to have it as simple as possible. I just hope that there are any additional restrictions due to ASUS. Good luck!




I will give this a try this afternoon. FYI I have used the auto setup 5-6 times trying various fixes and then blowing the disk away. Every time it has given me the same disk setup.


----------



## wblock@ (Apr 6, 2015)

Dual boot complicates this even more.  On Windows-specific systems, I'd suggest just leaving Windows on it and installing FreeBSD in VirtualBox.  In effect, use Windows as a VM and driver host.  Dual-booting off UEFI... well, it's surely possible, but I have not investigated it.

If you want to replace the machine, I'd suggest looking at Acer, Dell, and Toshiba (Acer-made) that are one or two CPU generations old.  I recommend avoiding HP, Lenovo, and Asus for differing reasons.  (Please start a new thread if you want to discuss that.)


----------



## verus (Apr 6, 2015)

wblock@ said:


> Dual boot complicates this even more.  On Windows-specific systems, I'd suggest just leaving Windows on it and installing FreeBSD in VirtualBox.  In effect, use Windows as a VM and driver host.  Dual-booting off UEFI... well, it's surely possible, but I have not investigated it.



Right now I am just trying to get BSD to boot on this laptop. Using BSD in a VM with Windows underneath would not be the best solution for me.


----------



## swirling_vortex (Apr 7, 2015)

Funny, I've been hitting my head on the same issue. Except in my case, the motherboard doesn't see the UEFI system at all. I'm never presented with any option with booting unless I install FreeBSD the legacy way. I can boot from the CD and install it, but that's it.

The weird thing is that the UEFI install does work inside of VirtualBox and Linux EFI stuff works fine, so it's probably due to the way each vendor implements it. I have an Asus laptop and an ASRock motherboard. Someone did submit a bug report about it, but there have been no follow-ups on it.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195719


----------



## verus (Apr 9, 2015)

swirling_vortex said:


> Funny, I've been hitting my head on the same issue. Except in my case, the motherboard doesn't see the UEFI system at all. I'm never presented with any option with booting unless I install FreeBSD the legacy way. I can boot from the CD and install it, but that's it.
> 
> The weird thing is that the UEFI install does work inside of VirtualBox and Linux EFI stuff works fine, so it's probably due to the way each vendor implements it. I have an Asus laptop and an ASRock motherboard. Someone did submit a bug report about it, but there have been no follow-ups on it.
> 
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195719




I'm guessing that you are dual booting?


----------



## verus (Apr 9, 2015)

OK,

So advice on another forum leads me to think that the EFI loader is working but the kernel is dying immediately. The ACPI driver? maybe? https://www.freebsd.org/cgi/man.cgi?query=acpi&sektion=4

How can I disable ACPI after install, or from the loader?


----------



## swirling_vortex (Apr 10, 2015)

verus said:


> I'm guessing that you are dual booting?


No. Clean install.


----------



## dcol (Jul 31, 2017)

I have never been able to install FreeBSD version 11 on any of my Dell Optiplex's (7010,7020,7040) in UEFI mode. Always hangs at the beastie logo.
I install using ZFS with GPT under legacy mode. After install, only way to boot UEFI is manually through the boot menu. Legacy boot always works.
There is definitely a bug in the FreeBSD boot loader. Every other Linux distro I have tried works fine.


----------



## drhowarddrfine (Jul 31, 2017)

dcol You are responding to a more than two-year old thread.


----------

