# FreeBSD does not start on a triple boot with Grub2



## Halberdier (May 3, 2011)

Hello everybody,

I would like to experiment with FreeBSD. As I already have a dual booted machine (Ubuntu 10.10 and Windows XP) with plenty of disk space, I attempted a triple boot. First, I prepared the .img on a USB flash. As I messed up with *dd* from Linux, I used Image Writer from Windows XP. Then, I booted from the flash and Synopsis worked properly. When creating the partition, I refused the default geometry, and Synopsis detected the CHS combination matching with that showed by GParted in Linux. Having 300G for Linux and 100G for Windows, I allocated 100G to FreeBSD, then I clicked on A for automatic partition usage. I didn't install the FreeBSD boot manager, as I wanted to continue using Grub2.

At this point, I had warnings on all the four partitions (Linux, Windows, FreeBSD and Swap), stating that they don't start on a disk sector. The installation went on to completion, though. Now I went back on Linux. On GParted the FreeBSD partition shows as unknown. I edited the /etc/grub.d/40_custom file by adding the following lines:


```
menuentry "FreeBSD 8.2 - RELEASE amd64" {
set root=(hd0,msdos4)
chainloader +1
}
```

I used msdos4 mimicking the syntax that GRUB already used for the other systems, considering the partitions as numbered 1 to 4. Finally I updated grub.cfg with *update-grub*. When selecting FreeBSD from GRUB, it does not start, with a generic error message.

I think this post is long enough for now. I will add details later, as I don't know at the moment what could be useful for the experts. Thank you all in advance for your attention.


----------



## ahavatar (May 3, 2011)

Check if the FreeBSD partition is indeed the 4th partition, in other words, on GParted running on Linux, it should be "/dev/sda4"

And in my case, I use (hd0,4) instead of (hd0,msdos4). I don't know if (hd0,4) is same as (hd0,msdos4).


----------



## Halberdier (May 3, 2011)

Thank you for your prompt reply. FreeBSD is actually "/dev/sda4" on GParted. I used msdos4, as the automatically detected boots in GRUB were compiled as (hd0,msdos1) for /dev/sda1 (Ububntu) and (hd0,msdos2) for /dev/sda2 (Windows). However, I'll try later with (hd0,4), to be sure. 

(I am now at work, the system we are talking about is at home).


----------



## francis (May 3, 2011)

As always - I recommended a great utility; EasyBCD. It is useful especially for booting Un*x-like systems and Windows. I think that, this program is usefull for beginners. 
Have fun in experimenting with FreeBSD!


----------



## Halberdier (May 3, 2011)

Thank you, I'll try it. For the record, (hd0,4) did not work, just the same as (hd0,msdos4). The error message, immediately after the GRUB selection, is:


```
error: not an assignment.
error: invalid signature.

Press any key to continue...
```


----------



## mlinuxgada (Sep 24, 2011)

Still the same problem with Grub2. 

```
error: invalid signature.

Press any key to continue...
```
PS:In Grub2 there's no option 'rootnoverify' ...


----------



## mlinuxgada (Sep 25, 2011)

Fixed it. There is a bug into grub2/spec options/, with grub everything is ok.


----------



## Halberdier (Oct 16, 2011)

Thank you all. I realized that grub2 has compatibility issues with a number of applications. I downgraded to grub for the Linux partition, then used GAG as a first stage boot loader: everything worked properly at the first attempt.


----------



## velikij (May 30, 2012)

Ubuntu (or the grub2 creators upstream) have improved OS scanning by Ubuntu 12.04. I have a system running XP, FreeBSD 8.1, and Ubuntu, and did not install a FreeBSD boot manager. Before Ubuntu 12.04, I had to create a custom /etc/grub.d/40_custom file before running *update-grub* on the Linux partition. 

But now running *update-grub* will detect my FreeBSD properly, so I was able to remove the custom file.

However I was able to use the custom file - mine looks like


```
#!/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 8.1 manual by Peter" {
      set root=(hd0,3)
      chainloader +1
}
```
Under Ubuntu 12.04, the generated stanza for FreeBSD in /boot/grub/grub.cfg is


```
menuentry "FreeBSD 8.1-RELEASE (GENERIC) (on /dev/sda3)" --class windows --class os {
  insmod part_msdos
  insmod ufs2
  set root='(hd0,msdos3)'
  search --no-floppy --fs-uuid --set=root 4b2e8da4ae6a55e3
  drivemap -s (hd0) ${root}
  chainloader +1
}
```


----------

