# FreeBSD + GPT + UEFI



## abbec (Oct 26, 2013)

Hello!

I tried installing Freebsd FreeBSD 10-BETA1 and the installation went well but when I reboot it just shows me BIOS settings. So my first step was to disable secure boot and enable CSM (all setting set to legacy mode) in the bios settings but nothing seems to help.

The disks were partitioned with guided partitioning using the whole disk, so the format is GPT.

The motherboard in question is an Asus MAaximus VI Impact.

Do I need to do something special during the installation and is this supposed to work?

Thanks!


----------



## abbec (Oct 26, 2013)

Could it be that my BIOS assumes UEFI based on the fact that the disk is GPT? I can still boot the system by using a bootloader from USB but is less than ideal


----------



## Saeediranzad (Oct 28, 2013)

Hi!

It seems nobody knows a solution. Actually it's the same problem with my FreeBSD installed on my SD memory card. My laptop has an ordinary BIOS and partitioned in MBR and is triple boot and works well. But when I want to boot it from my SD which has a GPT partitioning it stalls and can not find boot loader. I tried to install FreeBSD as MBR, but it gave me error and I couldn't change it.

Anyway, have you tried to change your BIOS to UEFI?


----------



## abbec (Oct 28, 2013)

Changing the BIOS to UEFI will hardly solve anything since FreeBSD is the only system on the disk and cannot be booted in UEFI mode. Another idea is to use a UEFI bootloader like GRUB2 and then chainload into freebsd. Do you guys think that would work?


----------



## J65nko (Oct 28, 2013)

abbec said:
			
		

> The disks were partitioned with guided partitioning using the whole disk, so the format is GPT.


If you boot the installer and choose LiveCD/DVD, what is the output of `# gpart show`?


----------



## SirDice (Oct 28, 2013)

You need to enable "Legacy Boot" in CSM. That's the only way FreeBSD will boot.


----------



## Beeblebrox (Oct 28, 2013)

> Another idea is to use a UEFI bootloader like GRUB2 and then chainload into freebsd. Do you guys think that would work?



Grub from ports does not work with zfs-ver5000, which is the default in FreeBSD 9+. If your filesystem is non-zfs or a lower version of it, then grub will work very nicely. Otherwise, you must compile from the bazaar source repository.


----------



## abbec (Oct 29, 2013)

SirDice said:
			
		

> You need to enable "Legacy Boot" in CSM. That's the only way FreeBSD will boot.



As I said in my original post I already did that. However, my suspicion is that this is ignored when it detects that the drive is GPT. Seen some reports of that behavior.


----------



## abbec (Oct 31, 2013)

I read this on the UEFI wiki page under "Real Hardware Gotchas":

"Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive."

Could this be the cause?


----------



## SirDice (Oct 31, 2013)

abbec said:
			
		

> As I said in my original post I already did that. However, my suspicion is that this is ignored when it detects that the drive is GPT. Seen some reports of that behavior.


Not on my machines. They boot perfectly fine with GPT, as long as I use legacy boot.


----------



## ronaldlees (Oct 31, 2013)

This is a continual aggravation, especially for people who like to monkey around with (very) old hardware and operating systems. GRUB2 (and some incantations of GRUB1)  can work, and I've found it is possible to finesse everything, and tweak it just right to get it working, with hassle. There's always something I forget when I'm in the process of switching things around, and mixing and matching GPT aware and unaware systems. In the end, I just dedicated the entire hard disk to FreeBSD, made dedicated USB boot sticks for other newer things, and keep junker hardware around for the really old OSes.

Haiku-OS on a stick is as fast as can be, especially for net browsing. One of these days, I'll completely dispense with hard drives altogether, and just carry a big pocketful of USB sticks.

The other day, I used FreeBSD 6 inside of Virtualbox, running on a FreeBSD-9.1 USB stick. No problems.


----------



## abbec (Oct 31, 2013)

The output of `gpart show` is:


```
=>       34  468862061  ada0  GPT  (224G)
         34          6        - free -  (3.0K)
         40        128     1  freebsd-boot  (64K)
        168  461373304     2  freebsd-ufs  (220G)
  461373472    7488622     3  freebsd-swap  (3.6G)
  468862094          1        - free -  (512B)
```


----------



## abbec (Oct 31, 2013)

abbec said:
			
		

> I read this on the UEFI wiki page under "Real Hardware Gotchas":
> 
> "Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive."
> 
> Could this be the cause?



Still think this might have been the cause but, I reinstalled with MBR (since I do not really need GPT anyway  ) and that worked perfectly!

Thanks for all the help guys!


----------



## zspider (Nov 1, 2013)

abbec said:
			
		

> Still think this might have been the cause but, I reinstalled with MBR (since I do not really need GPT anyway  ) and that worked perfectly!
> 
> Thanks for all the help guys!



I sometimes think that might of been the case with mine as well, but I cannot test without significant work, as I don't have any other laptop drives around. But when the opportunity presents itself again I will definitely be trying disabling the active flag.


----------



## gug (Dec 27, 2013)

> "Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive."


I had the same problem using GPT partitions on an Asus z87-ws motherboard with FreeBSD 10-RCx. I had to enable/disable the active flag after sysinstall ends to make it work.

`gpart set -a active adaX`


----------



## kegwin (Jan 16, 2014)

gug said:
			
		

> > "Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive."
> 
> 
> I had the same problem using GPT partitions on an Asus z87-ws motherboard with FreeBSD 10-RCx. I had to enable/disable the active flag after sysinstall ends to make it work.
> ...



`gpart set -a active adaX` worked for me. Thank you!


----------



## maxidlabs (Jan 18, 2014)

Thanks for help! The `gpart set active` method worked for me. Motherboard Asus Z87 Plus.


----------



## nekoexmachina (Jan 27, 2014)

bump

`gpart set -a active ada0` didn't work well for me; actually nothing at all changed (u32vj asus laptop). Shame it is.
Installation to MBR was painfully slow and disk is painfully (again) slow when using MBR, which should be the result of 4k aligned disk (but I didn't expect to non-aligned disk work 5 times slower than aligned..).
Okay.
Will test with proper hdd setup tomorrow, then..


----------



## pva (Feb 17, 2014)

gug said:
			
		

> > "Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive."
> 
> 
> I had the same problem using GPT partitions on an Asus z87-ws motherboard with FreeBSD 10-RCx. I had to enable/disable the active flag after sysinstall ends to make it work.
> ...



Thanks @gug! This allowed me to boot FreeBSD 10.0-RELEASE on a ASRock C2550D4I using GPT.


----------



## yom (Mar 10, 2014)

gug said:
			
		

> > "Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive."
> 
> 
> I had the same problem using GPT partitions on an Asus z87-ws motherboard with FreeBSD 10-RCx. I had to enable/disable the active flag after sysinstall ends to make it work.
> ...


This also worked for me 

Great !
FreeBSD is running like a charm


----------



## GooseYArd (Apr 12, 2014)

I want to hug this thread. Solved several hours of frustration with a new Asus H87I-PLUS motherboard as well. Thanks everybody!!


----------



## bernux (Jun 25, 2014)

gug said:
			
		

> > "Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive."
> 
> 
> I had the same problem using GPT partitions on an Asus z87-ws motherboard with FreeBSD 10-RCx. I had to enable/disable the active flag after sysinstall ends to make it work.
> ...



Thanks a lot! This command saved my life after migrate to an Asus Z97-A motherboard.


----------



## redjupiter (Jun 27, 2014)

gug said:
			
		

> > "Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive."
> 
> 
> I had the same problem using GPT partitions on an Asus z87-ws motherboard with FreeBSD 10-RCx. I had to enable/disable the active flag after sysinstall ends to make it work.
> ...



This worked for me too on Asus H81M-K motherboard with no legacy boot. (I spent days searching for a way to boot FreeBSD 10). thanks


----------



## rotochamp (Jun 27, 2014)

redjupiter said:
			
		

> gug said:
> 
> 
> 
> ...




This also solved my problem installing on an Asus Sabertooth X79, so thanks  :beergrin


----------



## doa379 (Jul 10, 2014)

Count me in too on this issue.
+1 LOL

HP 2170p Legacy Boot with GUIDPT FreeBSD-10-amd64.


----------



## zac (Jul 13, 2014)

Chock up another victory for manually setting the partition active.  Intel Pentium-D (dual core, 32-bit) motherboard.  Thank you!


----------



## gkbsd (Jul 27, 2014)

Hello,

This did not work for me unfortunately. No matter the BIOS settings (AHCI, SATA only/combined/enhanced), no matter I install FreeBSD 10-RELEASE amd64 with GPT or MBR, the `gpart set -a active ada0` changes nothing for me. I have an MSI 975X Platinum motherboard bought in 2007, with the last BIOS available, and a single 1TB HDD SATA2 drive plugged in. If I plug my main HDD instead, others OS boot fine, either Windows or Linux. I created 6 partitions, including swap : /, swap, /var, /tmp, /usr, and /data. What else could I try?

Guillaume.


----------



## wblock@ (Jul 27, 2014)

A 2007 machine does not have UEFI, but BIOS.  Some buggy BIOS systems will not boot unless one of the MBR partitions is set active.


----------



## gkbsd (Jul 27, 2014)

I know my motherboard does not have UEFI, but I was advised to take a look at this thread and try again with GPT, and as nothing worked, I tried to set an active partition with gpart, using MBR too. It does not boot either. I guess it's time to buy a new computer.

Guillaume.


----------



## gkbsd (Jul 27, 2014)

My post is here : viewtopic.php?f=4&t=47368&p=264641#p264641

I will update it with the commands I do and their output.

Guillaume.


----------



## wblock@ (Jul 27, 2014)

This is my fault.  @gkbsd did start a new thread: https://forums.freebsd.org/viewtopic.php?f=4&t=47368, and I referred him to this one as possibly related.  But if it is related, it's the opposite way.  Sorry about that.


----------



## Yri (Oct 20, 2014)

gug said:


> I had the same problem using GPT partitions on an Asus z87-ws motherboard with FreeBSD 10-RCx. I had to enable/disable the active flag after sysinstall ends to make it work.
> 
> `gpart set -a active adaX`



Registered here to say THANK YOU! 
FreeBSD-10-amd64, ASUS Z97-A, RAID1
`#gpart set -a active raid/r0`


----------



## free-and-bsd (Dec 5, 2014)

FreeBSD + GPT (+ZFS) + GRUB2 works OK. With GRUB2-EFI it can be made to work, but takes some tuning.


Saeediranzad said:


> Hi!
> 
> It seems nobody knows a solution. Actually it's the same problem with my FreeBSD installed on my SD memory card. My laptop has an ordinary BIOS and partitioned in MBR and is triple boot and works well. But when I want to boot it from my SD which has a GPT partitioning it stalls and can not find boot loader. I tried to install FreeBSD as MBR, but it gave me error and I couldn't change it.
> 
> Anyway, have you tried to change your BIOS to UEFI?


I don't know about SD card, I could never make it boot at all.
With HDDs or USB sticks it's easier. Though I've been using GPT for a long time, for it's easier to handle.
First: switch your UEFI settings to legacy mode ("BIOS" mode). Then, given that your disk is GPT, follow one of the numerous guides on how to MANUALLY install bootcode onto a GPT disk. That is done by first choosing "Shell" option from your FreeBSD installer-CD (or USB stick or whatever media you're using). Then from the shell you execute your commands like this:

```
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
```
This command implies you have partition #1 of type freebsd-boot on your /dev/ada0 and your system partition is of type freebsd-zfs. If it is freebsd-ufs, you'll need the option `-p /boot/gptboot` instead of `-p /boot/gptzfsboot` into the command above. To know exactly what your disk in question is use `gpart show` command.

Take a look at this guide for example, just instead of freebsd-zfs you can use freebsd-ufs partition type etc. Yet I think the standard installer should have handled partitioning well enough. Just use the command above to fix the bootloader.
There shouldn't be any need to set "active partition" with this setup, I think.


----------

