# Disk not recognized in UEFI post-installation



## Paul Mesnilgrente (Feb 7, 2015)

Hello,
I am new in FreeBSD and I have a problem with the installation.
I have a laptop Asus s400ca-ca010h. The bios version is 209 (the last one is 210). I have disabled secure boot and flash boot. My SATA configuration (SATA Mode Selection) is on AHCI, may I use IDE?

Image: FreeBSD-10.1-RELEASE-amd64-uefi-memstick.img
I put this image on a 3.0 USB key.

There are two disks on this computer: a SSD with 24GB, a HDD with 500GB. I first installed FreeBSD on the HDD, but when I started, the HDD was not listed in the UEFI boot option.
I try then with the SSD, the same happened.

What is the problem? I used the guided partition, it made a first slice with efi type (800KB), a freebsd-ufs type (400GB, mountpoint /), and the swap.

I do not know what to do. Ask me if you want to know more.

Sorry for my English, I'm French...


----------



## Paul Mesnilgrente (Feb 7, 2015)

Someone said to me it was maybe the USB 3.0 key, so I tried with a 2.0 USB key with the 2.0 USB port and the result is the same.
Why can't I see his post ?


----------



## Juanitou (Feb 7, 2015)

Paul Mesnilgrente said:


> Why can't I see his post ?


getopt has deleted it, I don't know why.


----------



## Paul Mesnilgrente (Feb 7, 2015)

It was not a good advice he said to me...


----------



## wblock@ (Feb 7, 2015)

I would suggest enabling legacy boot and installing a with a normal, non-UEFI install disk.


----------



## Paul Mesnilgrente (Feb 8, 2015)

I did what you say, I have downloaded the FreeBSD-10.1-RELEASE-amd64-memstick.img file. I put it on my usb 2.0 key. I install the system, but it still does not recognize hard disks in the uefi bios.
The system chose a gpt partition table with the guided partition, is that good ?

And the documentation say :

ACPI Support: If the system hangs during boot, try toggling this option to Off.


Safe Mode: If the system still hangs during boot even with ACPI Support set to Off, try setting this option to On.
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/bsdinstall-start.html
paragraphe 2.4.4
is that for the installation boot or the post-installation boot ? I have not try that yet.


----------



## kpa (Feb 8, 2015)

Paul Mesnilgrente said:


> And the documentation say :
> 
> ACPI Support: If the system hangs during boot, try toggling this option to Off.



I wish this part of the handbook wasn't so horribly out of date. Turning off ACPI was a plausible workaround some 10 years ago when ACPI was a new thing on the scene but on any recent machine it does absolutely nothing. Modern machines depend on ACPI to work properly and there's no reason to turn it off.


----------



## Paul Mesnilgrente (Feb 8, 2015)

So I do not know what is the problem :/


----------



## wblock@ (Feb 8, 2015)

kpa said:


> I wish this part of the handbook wasn't so horribly out of date.


Agreed.  If you'd like to update the content, I'm willing to help with markup and editing.


----------



## Paul Mesnilgrente (Feb 9, 2015)

I reinstalled Ubuntu 14.04 like this:





and my home is on sda :





sda2 contains efi partition (did I need it ?)
sda3 contains /
sda4 contains swap

I put

```
menuentry "FreeBSD 10.1 Uefi" {
  insmod ufs2
  set root=(hd0,gpt3)
  kfreebsd /boot/loader
}
```
in /etc/grub.d/40_custom as said in http://blog.leahhanson.us/notes-on-installing-and-booting-freebsd-from-grub2.html.  But when I boot on FreeBSD with grub menu, it displays a purple screen with black rectangle. And it stays like that.

How can I debug this bug?


----------



## Paul Mesnilgrente (Feb 10, 2015)

I don't know what to do, I think that I will reinstall Ubuntu 14.04 in non-EFI mode, and FreeBSD too. But I don't really believe in that...
If it could output just one message to have a clue.
I have mounted the ufs partition, there is no /var/run/dmesg.boot, so I don't know what block the boot


----------



## JW0914 (Mar 2, 2015)

Does anyone have an actual solution (or even an explanation as to why this is occurring) to getting the efi boot partition recognized by the OS [FreeBSD 10.1] at boot?  (Simply telling someone to not use UEFI because the causation of the issue is not known by any one user is not only not an acceptable answer, if you have a newer MB that supports it , then you should be able to enable it with a compatible MB and OS.)

MB: AsRock C2750d4i
HDD: Samsung 850 EVO 120GB SSD (GPT; p1: 800k efi boot, p2: / 32GB, p3: /var 20GB, p4: /usr 25GB, p5: /home 35GB)
FreeBSD: x64, UEFI

If you create a USB (2 or 3) bootable install disk with the UEFI img, UEFI works fine and FreeBSD recognizes the efi boot partition on the install media.
If you create a DVD bootable install disk with the UEFI iso, UEFI works fine and FreeBSD recognizes the efi boot partition on the install media.
If you setup your HDD the same [a efi boot partition], UEFI does not work fine and FreeBSD does not recognize the efi boot partition.
If you use the UEFI install media to install FreeBSD and create a regular boot partition [instead of efi], FreeBSD boots fine with no issue.
The efi boot partition isn't recognized by the OS regardless if you allow FreeBSD to auto configure the partition or if you do it manually via shell.
I've tried changing CSM from UEFI only to UEFI and Legacy, which is recommended here http://forums.freebsd.org/threads/freebsd-gpt-uefi.42781/ however I switched it after installing FreeBSD 10.1... does it need to be set to both _*prior*_ to install?

This proves FreeBSD, upon install, is not configuring a file(s) it needs to configure for UEFI to work properly and the efi boot partition to be recognized. If it was an issue or bug within FreeBSD 10.1, wouldn't recognize and boot from the efi partitions on the USB and DVD install medias.  I know squat about unix systems and only know as much about FreeBSD as I've learned over the past week of trying to get UEFI to work right on my newly built NAS server; therefore, if someone more knowledgeable than me can either explain, or point me in the right direction of where to look for an answer, I would be extremely appreciative.


----------



## georges (Mar 16, 2015)

I am not sure if your problem is similar to mine ... I am still learning too.

My machine UEFI only.

I installed FreeBSD on the hard disk successfully. Similar to you, the drive is not recognized and I can not boot FreeBSD.

I then reinstalled again, this time I dropped to a shell before rebooting and used gpart to check and I found out that the partition was not active.

So I set it to active `gpart set -a active <drive|partition>` and it booted (can't remember the exact syntax)


----------



## Chris_H (Mar 17, 2015)

IMHO the "Guided Partitioning" has other issues, as well. I'm not her to whine about it. In fact I'm currently working on a solution I hope to have complete soonish. So I can offer it for evaluation. In it's current state, the Guided Partitioning should guide you away from itself, and to a shell with the commands most commonly used/needed, echoed to the screen.
The best advice I could give anyone intending to install FreeBSD, would be to carefully examine the gpart(8), and newfs(8) man(1) pages prior to install. One *should* do that anyway, no? 

--Chris


----------



## Alberto Calanna (Aug 26, 2016)

*SOLVED.*
I have had your same problem. (UEFI installations media are recognized by my pc as UEFI units, but after installation my FreeBSD-10.3 disk was not recognized  as UEFI disk.

Also, I was sure there wasn't no problem concerning my BIOS/UEFI firmware, my motherboard and my hard disk because PC-BSD-10.3, installed a week before into the same disk, was perfectly recognized as UEFI unit.

So, after some search relative to UEFI and UEFI structure into the file system I realized the follow:

1)The efi partition must be at least 160MB (mine is 320M)
2)The efi partition must have to be formatted as msdos fat16 or fat32 (mine is fat16)
3) The bootloader must be copied into EFI/BOOT and *renamed* as BOOTX64.EFI

In short... if your disk is ada0

Create and format the EFI partition:

```
# gpart add -t efi -l efipart -a4k -s320M ada0
ada0p1 added
# newfs_msdos -F 16 /dev/ada0p1
```

Copy (and rename) the bootloader inside it:

```
# mount -t msdosfs /dev/ada0p1 /mnt
# mkdir -p /mnt/EFI/BOOT
# cp /boot/boot1.efi /mnt/EFI/BOOT/BOOTX64.EFI
# umount /mnt
```

...and continue with the installation of your system...

Now reboot into BIOS and check that all the UEFI setting are properly enabled (but not the secure bootloader).

Now you have a recognized UEFI disk...


----------



## redpill (Oct 4, 2016)

I came across this thread a few times in my own UEFI battle over the weekend, so I thought I'd share a few things that I learned that I haven't seen brought up in any of the documentation or posts that I read.

For starters, the FreeBSD installer--from my experience, at least--actually does a fine job of setting up the EFI System Partition (ESP). So you should be able to use the guided partitioning tool if you don't want to do things manually. It certainly doesn't hurt to know how to setup your ESP manually, but this is not likely to be the cause of most problems. What the installer does _not_ do, from what I can tell, is explicitly add an entry pointing to FreeBSD's EFI loader to the UEFI's NVRAM. Instead, it seems to rely on automatic detection by storing the loader at /efi/boot/bootx64.efi.

Obviously, this doesn't work for everybody. And I suspect it's particularly problematic for those who have one or more other operating systems installed on the same machine. Windows and Solaris, for example, provide their own copy of /efi/boot/bootx64.efi in their respective ESPs. Which one does the UEFI load? Fortunately, you don't need to rely on automatic detection. So how do you add FreeBSD's EFI loader to your UEFI's boot menu?

Unfortunately, there doesn't appear to be a way to do this from FreeBSD. (I'd love to be told I'm wrong about this.) Your best bets are either

an EFI Shell, from which you can use the `bcfg` command, or
Linux, which can do this via `efibootmgr`.
Option 1 is somewhat cumbersome to use--even after you've found a way to boot an EFI Shell--so I'm going to briefly describe Option 2 here. Note that you don't actually need to have Linux installed on your system; a LiveCD/USB/whatever that contains `efibootmgr` will suffice. Obviously, this is something you would do after completing the FreeBSD install.

So let's say your EFI System Partition is on /dev/ada1p3 and you've copied the loader to /efi/freebsd/boot1.efi. The command you'd use is

`# efibootmgr -c -d /dev/sdb -p 3 -l \\efi\\freebsd\\boot1.efi -L FreeBSD`

As you can see, the only thing you'll have to look out for is the different device names used by Linux. And if you haven't mucked about the partition created by the installer then the loader will still reside under /efi/boot/bootx64.efi (as mentioned earlier).

Hopefully, this works for some of you folks as well as it did for me. No promises though.


----------



## scottro (Oct 9, 2016)

I also ran into this the other day, playing with UEFI, using a Fedora system.

A few minor differences.  I only needed single backslashes for the path to the FreeBSD bootloader, e.g. `-l \EFI\FreeBSD\BOOT\BOOTx64.EFI`.  (For whatever reason, it was in upper case.
Then,  once I did this, it would boot into FreeBSD, but I wasn't able to get back to Linux.   However, (this was on a VirtualBox installation that I was using for testing), I could then, as it booted, hit the escape key, which would bring up a menu, giving me a choice of the Fedora or FreeBSD install.  Back in Fedora, I could run efibootmgr with no arguments to see what number was assigned to each one.  If FreeBSD was something004 (I've forgotten the exact listing now) I could do `efibootmgr -n 0004` and next time it would boot into FreeBSD. (But to get back to Fedora, I would have to hit escape as it booted, to get back to an EFI menu allowing me to choose one or the other.)


----------

