# Configure GRUB to boot FreeBSD



## absolutezero1287 (May 23, 2007)

I have a dual boot setup with Ubuntu and FreeBSD. The FreeBSD partition is mounted on /dev/sda3. So I figured that the entry in menu.lst would look like this:

title FreeBSD 7.0
root (hd0,3)
kernel /boot/loader

But then I get a message saying that that partition doesn't exist. Any suggestions?


----------



## absolutezero1287 (May 23, 2007)

For those who need it, here's my GRUB configuration.

# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 3

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
hiddenmenu

# Pretty colours
#color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader	+1
#
# title Linux
# root (hd0,1)
# kernel	/vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
## kopt_2_6_8=root=/dev/hdc1 ro
## kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=d60fc9cb-4b80-46bc-88f2-7edf65190e90 ro

## Setup crashdump menu entries
## e.g. crashdump=1
# crashdump=0

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,0)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
## lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title Ubuntu 7.10, kernel 2.6.22-14-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.22-14-generic root=UUID=d60fc9cb-4b80-46bc-88f2-7edf65190e90 ro quiet splash
initrd /boot/initrd.img-2.6.22-14-generic
quiet

title Ubuntu 7.10, kernel 2.6.22-14-generic (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.22-14-generic root=UUID=d60fc9cb-4b80-46bc-88f2-7edf65190e90 ro single
initrd /boot/initrd.img-2.6.22-14-generic

title Ubuntu 7.10, memtest86+
root (hd0,0)
kernel /boot/memtest86+.bin
quiet

title FreeBSD 7.0
root (hd0,3)
kernel /boot/loader

### END DEBIAN AUTOMAGIC KERNELS LIST


----------



## lotuseclat79 (Sep 12, 2003)

Using Ubuntu, from the root account, issue the command:
# fdisk -l
and post the result in this thread.

I suspect that to make your scheme work with Grub, you may need to repartition FreeBSD to have a /boot partition separate from its main active partition - but, I am not sure, OTOH, you may simply be missing the partition id for your FreeBSD partition. saikee (a member here at TSG) may know the answer off the top of his head as I'm sure he may even have encounter this problem before.

You should note that FreeBSD will not be using any Linux filesystem partitions usually with an ID of 82 for swap, and 83 for either /boot or / root partitions that Grub (being a Linux bootloader probably knows about). The missing information needed for your Unix partition from the screenshot attachment you posted can probably be found here which lists a table of partition ids for PCs. Note: FreeBSD is a5. I would first try assigning a5 to the FreeBSD partition id field with your partitioning software. From your menu.lst entry, it looks to be what the Gnu Grub manual 0.97 specifies, so maybe all you are missing is the partition id specification for FreeBSD in the partition table. In fact, checking with saikee's post for  A grub menu booting 100+ systems of Dos, Windows, Linux, BSD and Solaris, it looks like that might be the aswer.

Also, here is a link to How It Works: Partition Tables which may help you understand what you have to do to make your scheme work with Grub further if the above suggestion does not solve your problem, although, I suspect it will.

-- Tom


----------



## absolutezero1287 (May 23, 2007)

Another little bit of info:

fdisk -l /dev/sda

Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd0f4738c

Device Boot Start End Blocks Id System
/dev/sda1 1 4732 38009758+ 83 Linux
/dev/sda2 9465 9726 2104515 5 Extended
/dev/sda3 * 4733 9464 38009790 a5 FreeBSD
/dev/sda5 9465 9726 2104483+ 82 Linux swap / Solaris

Partition table entries are not in disk order


----------



## saikee (Jun 11, 2004)

Try this in menu.lst

```
title FreeBSD 7.0 in sda3 but dude said it is (hd0,2)
root (hd0,2)
chainloader +1
```
FreeBSD has BSDsubparts that work like logical partitions and its boot loader may be in one of the subparts. In a standard installation it is a lot easier to chainload the BSD bootloader than to ask Grub to fire the BSD up. The difference is to let Grub boots FreeBSD boot loader and the FreeBSD boot loader boots the BSD system.

The partition type a5 is standard for FreeBSD and its variants.


----------



## absolutezero1287 (May 23, 2007)

I'm gonna try this:

title FreeBSD 7.0
root (hd0,3,a)
kernel /boot/loader
chainloader +1

BBL to see if it works.

Thanks everyone for all your input.

Looks like my method didn't work. Saikee, I'm gonna try your method.


----------



## absolutezero1287 (May 23, 2007)

Here's a pic from Ubuntu. Why are there so many partitions? Lol.


----------



## absolutezero1287 (May 23, 2007)

Well, with my previous configuration:

title FreeBSD 7.0
root (hd0,3,a)
kernel /boot/loader
chainloader +1

it said that it couldn't find the partition. But with the current configuration:

title FreeBSD 7.0 in sda3 but dude said it is (hd0,2)
root (hd0,2)
chainloader +1

It said that it can't mount the partition.

To my understanding, this means that GRUB can't handle BSD partitions or that I simply have the wrong partition.

On a side note: I was told that I could have GRUB load the FreeBSD bootloader which would in turn be able to handle my FreeBSD partition(s).


----------



## absolutezero1287 (May 23, 2007)

saikee said:


> Try this in menu.lst
> 
> ```
> title FreeBSD 7.0 in sda3 but dude said it is (hd0,2)
> ...


I tried it out but to no avail. Would I need to install the FreeBSD bootloader?
By default it installs it to the MBR, but I'm worried that it may screw with Ubuntu.

BTW, your post in justlinux.com rocks


----------



## lotuseclat79 (Sep 12, 2003)

absolutezero1287 said:


> I tried it out but to no avail. Would I need to install the FreeBSD bootloader?
> By default it installs it to the MBR, but I'm worried that it may screw with Ubuntu.
> 
> BTW, your post in justlinux.com rocks


Hi,

The line:
kernel /boot/loader
in your menu.lst entry assumes that the FreeBSD bootloader is installed in /boot/loader if I am not mistaken.

-- Tom


----------



## saikee (Jun 11, 2004)

The chainloader +1 only works if you have installed the boot loader in the root partition (sda3) of FreeBSD.


----------



## absolutezero1287 (May 23, 2007)

Oh, I see. So the bootloader must be installed in sda3...I'm gonna give it a shot.


----------



## danielcc (Mar 4, 2008)

the line for free bsd should be as follows:
title FreeBSD 7.0
root (hd0,2)
kernel /boot/loader

now let me explain why... the title is of course the title. the root is where the partition is located going from 0 as one on up(drive,partition#) your number for bsd is sda3 so it will be a two instead of a 3. the kernal is of course the kernal.... so yeah change that one number and you should be good to go...


----------

