# Multibooting under Grub- some questions



## jrl1357 (Jan 15, 2013)

*A*fter I bit on just Linux I'm coming back to freebsd FreeBSD. I installed it next to my current Debian squeeze and LMDE installs, like so:


```
/dev/sda1- bios_boot
/dev/sda2- (linux) /boot
/dev/sda3- linux-swap
/dev/sda4- Debian
/dev/sda5- LMDE
/dev/sda6- FreeBSD
/dev/sda7- nothing
/dev/sda8- (linux) /home
```
(of course it's slices from freebsd FreeBSD, but you get the point)

*T*he end goal is to have freebsd FreeBSD using the same swap if possible, and most import*a*ntly using the same /home mounted as ext2, as I don't think I'm using any of the features in ext4 that make it unmountable as ext2; but that's not for this thread.

*S*o my bootloader (grub-pc) is at version 1.98 in debian squeeze. I can find some info on the web but a lot is outdated and a lot of conflicts, and I've never been quite sure with how grub labels partitions. *I*f I am correct I would put this:


```
title  FreeBSD 9.1
root   (hd?,?)
kernel /boot/loader
```

*W*hat do I add for the numbers? is that even correct? *P*lease help.


----------



## jrl1357 (Jan 15, 2013)

*S*o I added:

```
menuentry 'FreeBSD 9.1' {
    set root='(hd0,6)'
    chainloader +1
}
```

to 40_custom. After running *update-grub* it shows me 'FreeBSD 9.1' upon enter it says 'invalid signature' 'any key to continue' hitting any key brings me back to the menu. Does anyone know what to do?

EDIT--

I also tried using hd0,5 instead of 6 in case it counts 0, no prize.


----------



## scottro (Jan 15, 2013)

From the menu entry, it looks like you're using grub2.

If so, I have success with 

```
chainloader (hd0,6)+1
```

I remember, many years ago, legacy grub requiring a space before the +1, but I just looked at a laptop with Fedora.  I see that I have it the way I've written it above, no space before the plus sign.

Then, if using 40_custom, you have to run, in Debian and Debian based systems

```
grub-mkconfig -o /boot/grub/grub.cfg
```

(I think--I've been using Fedora which uses the command grub2-mkconfig and the path /boot/grub2/grub.cfg)

Not sure if you can use the same swap for Linux and FreeBSD, I'd have to google to confirm that one way or the other.


----------



## xeube (Jan 15, 2013)

Why don't you try to use Gag, the Graphical Boot Manager, which can be found here?


----------



## jrl1357 (Jan 16, 2013)

ran both update-grub and grub-mkconfig in that way, no luck. as for chainloader (hd0,6)+1, are you saying do this:

```
menuentry 'FreeBSD 9.1' {
    set root='(hd0,6)'
    chainloader (hd0,6)+1
}
```
?


----------



## jrl1357 (Jan 16, 2013)

after reading another thread I gave this a shot.


```
menuentry "FreeBSD 9.1" {
                insmod ufs2
                insmod gpt
                set root=(hd0,6)
                search --no-floppy --fs-uuid --set 4b22f9090565ab77
                freebsd                 /boot/kernel/kernel
                freebsd_loadenv         /boot/device.hints
                set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad4s1a
                set FreeBSD.vfs.root.mountfrom.options=rw
        }
```

gives the error 'device 4b22f9090565ab77 not found' and 'command freebsd not found' and 'command freebsd_load_env' not found. not sure what the number in the line search defines though, is it uuid or something?


----------



## cpm@ (Jan 16, 2013)

The command *chainloader +1* causes *GRUB* to read and execute the first sector of the specified partition.

Thats if your UFS/BSD slice is on /dev/sda6 (in linux):


> /dev/sda1 = hd0,0
> /dev/sda2 = hd0,1
> /dev/sda3 = hd0,2
> /dev/sda4 = hd0,3
> ...



Entry which boots FreeBSD into /etc/grub.d/40_custom add:

```
menuentry "FreeBSD 9.1" {
  insmod ufs
  set root=(hd0,5)
  chainloader +1
}
```

Be sure you run: 
`# grub2-mkconfig -o /boot/grub/grub.cfg`

Finally do *update-grub* from either distro.


----------



## scottro (Jan 16, 2013)

jrl1357 said:
			
		

> ran both update-grub and grub-mkconfig in that way, no luck. as for chainloader (hd0,6)+1, are you saying do this:
> 
> ```
> menuentry 'FreeBSD 9.1' {
> ...



Yes, that is what works for me.


----------



## jrl1357 (Jan 17, 2013)

both scottro's and cpu82s thoughts end with error: invalid signature. I tried both configs with both hd0,5 and hd0,6. Neither worked. I addedinsmod ufs to scottro's and tried both again and neither worked, with the same error, and at times also with error: file not found.


----------



## cpm@ (Jan 17, 2013)

Use grub2, instead grub package. Make sure that /dev/sda6 is bootable, add the line "GRUB_DISABLE_OS_PROBER=false" to the end of /etc/default/grub.

Assign execute permissions to /etc/grub.d/40_custom:

`# chmod +x /etc/grub.d/40_custom`

After check http://forums.freebsd.org/showpost.php?p=56726&postcount=10.

Try making the following changes:

```
menuentry "FreeBSD 9.1" {
                insmod ufs2
                insmod bsd
                search --no-floppy --fs-uuid --set=root UUID
                kfreebsd /boot/kernel/kernel
                kfreebsd_loadenv /boot/device.hints
                set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ufsid/UUID
                set kFreeBSD.vfs.root.mountfrom.options=rw
}
```

Replacing UUID of the disk discovered, run:

`# grub-probe -d /dev/sda6 -t fs_uuid`

Note that for other distros and *GRUB* versions, freebsd might have to be changed to just kfreebsd.


----------



## scottro (Jan 18, 2013)

For what it's worth, though I don't know if this will help. I have found that if I put a space before the +1 in the chainloader line, I get an error.  It should be the way I typed it, 
	
	



```
chainloader (hd0,6)+1
```
 and not 
	
	



```
(hd0,6) +1
```


----------

