# Dual Boot with Grub on Linux



## danaeckel (Dec 30, 2018)

Greetings,
   I have been struggling trying to setup my system to use Grub2. I have a dual drive system with GPT. My sda drive is installed with Ubuntu 18.10, while my sdb has FreeBSD 12 formatted with UFS. How should I setup my Grub config?

Thank you!


----------



## drhowarddrfine (Dec 30, 2018)

From what I read, grub2 is deprecated but there is a grub2-efi. What are you using?


----------



## T-Daemon (Dec 30, 2018)

drhowarddrfine, you missed the long description of the port sysutils/grub2-efi. If contains only the grub efi modules for EFI support, not the boot loader itself.  The main boot loader port is sysutils/grub2.

danaeckel, here is a minimal menu entry example for FreeBSD (in /etc/grub.d/40_custom - assuming you are configuring grub inside the Ubuntu installation). 

```
menuentry "FreeBSD 12.0-RELEASE" {
          set root='(hd1,gpt2)’ 
          kfreebsd /boot/loader
}
```
hd1 - (sdb)
gpt2 - FreeBSD root partition.

Before setting the menu entry you can list all devices and partitions known to GRUB from grubs boot menu. Press “ *c* “ at the boot menu. This drops you to a command line, there execute `ls`.

If FreeBSD does not boot from grub, go to the FreeBSD menu entry, press " *e* ", edit the gpt number and retry (that way you don't need to configure the file, update-grub, reboot, every time). On success make the change permanent in the configuration file.


----------



## free-and-bsd (Dec 30, 2018)

I just submitted a replacement for the deprecated sysutils/grub2. It is based on a recent enough snapshot (May, 2018), so it has the more or less up to date zpool features support etc. Don't know if that will be accepted, but it works fine for me.


----------



## drhowarddrfine (Dec 30, 2018)

T-Daemon said:


> The main boot loader port is sysutils/grub2.


I realize that but it's still deprecated and has no maintainer and hasn't been updated in five years.


----------



## emensee (Mar 21, 2019)

I have been trying to dual boot Linux and FreeBSD for quite sometime and finally got it working. The /etc/grub.d/40_custom entry in the linux (debian buster) install that worked for me is below. I set root to the efi partition installed by the FreeBSD installer. It can be found by hitting escape at the grub splash screen thereby going to the grub command line. Enter "ls (hd0 " then hit tab for tab completion which will list the disk partitions. A small (200mb) efi partition close to FreeBSD install should be listed. This partition in the below example is (hd0,gpt6). Change it to suit your installation.

Code:

```
menuentry "Freebsd 11.2" {
    set root='(hd0,gpt6)'
    chainloader (${root})/efi/boot/BOOTx64.efi
    boot
}
```
Don't put a space either side of the "=" sign. This alone cost me a lot of frustration. Use update-grub and reboot. Hope this helps someone.


----------



## penseleit (Feb 9, 2020)

Thanks.

That worked for me with FreeBSD installed on my NVME SSD _(hd0)_:

EFI partition is _(hd0,gpt1)_
root (/) partition is _(hd0,gpt2)_
swap partition is _(hd0,gpt3)_
And my menu entry in _/etc/grub.d/40_custom_ is:


```
menuentry "FreeBSD" {
    set root='(hd0,gpt1)'
    chainloader (${root})/efi/boot/BOOTx64.efi
    boot
}
```


----------



## F1R3-R4H (Feb 23, 2020)

Something rare happened to me: I was fighting for install freebsd 1X.x in my netbook, and when I boot, almost see that the USB has 13-Amd64; the strange was that I have x32 bits, don't know if my Linux Mint was programmed for this processor arch and I have another...
But going to the point: how should I configure which file for boot mine installation? See:
`cat /etc/grub.d/40_custom`
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "FreeBSD 12.0-RELEASE" {
          set root='(hd1,gpt2)’ 
          kfreebsd /boot/loader
}


----------

