Dual Booting Ubuntu Linux & FreeBSD using the new Grub2

Carlos A. M. dos Santos unixmania at gmail.com
Sun Nov 1 23:22:20 UTC 2009


On Sun, Nov 1, 2009 at 6:48 PM, Connor Imes <rocket2dmn at ubuntu.com> wrote:
> Ryan Wolf wrote:
>> To the Ubuntu & FreeBSD Documentation Folks:
>>
>> I spent all day trying to figure this out all because there isn't
>> proper documentation in books or on the internet on it, and no one's
>> documentation is up to date yet. After I figured it out, thought I
>> would put together a document so that others won't have to strain as
>> hard as I did just installing two operating systems that don't talk to
>> each other to well. I hope Ubuntu decides to have more support for
>> access to BSD partitions, as it doesn't seem to support it too well at
>> the moment.
>>
>> Enjoy the document guys. It's my first time writing one, so I hope it
>> helps.
>>
>> ~ Ryan
> That is a nice looking document, Ryan.  One of the Ubuntu Documentation
> contributors, drs305, has written (and been updating) a wiki page on
> Grub2, which you can find here [1].  It is geared toward Ubuntu users
> who have Grub2 installed from Ubuntu, but a lot of the basics should be
> applicable to FreeBSD as well.  You are welcome to expand on the wiki
> page, or if you host your guide on a FreeBSD site, please let us know.
> I don't believe the existing wiki page outlines multibooting in much
> detail yet, so your knowledge in this field would be very helpful.
>
> [1] https://help.ubuntu.com/community/Grub2

I'm 4-booting Ubuntu 9.04, FreeBSD 7, 8 and -CURRENT using GRUB. I had
to apply the following patch to grub2-1.96+20080512 in order to make
it pass the correct info to the FreeBSD loader because I'm using a
GPT-partitioned disk, with 17 partitions:

--- loader/i386/bsd.c.orig	2008-02-19 13:40:45.000000000 -0300
+++ loader/i386/bsd.c	2009-02-01 21:20:59.000000000 -0200
@@ -101,6 +101,8 @@

 	  if ((p[0] >= 'a') && (p[0] <= 'z'))
 	    *part = p[0] - 'a';
+	  else
+	    *part = 0xff;
 	}
     }
 }

FreeBSD boot partitions are 2, 5, 8. I created the following
"/etc/grub.d/10_freebsd" file, so "update-grub" does not remove
FreeBSD from the boot menu.

#!/bin/sh -e
cat << EOF
menuentry "FreeBSD 7-STABLE AMD64" {
	set root=(hd0,5)
	freebsd /boot/loader
}
menuentry "FreeBSD 8-STABLE AMD64" {
	set root=(hd0,8)
	freebsd /boot/loader
}
menuentry "FreeBSD 9-CURRENT AMD64" {
	set root=(hd0,2)
	freebsd /boot/loader
}
EOF

Then I created a "/etc/grub.d/01_casantos" file, to unset the defult
OS and timeout:

#!/bin/sh -e
cat << EOF
unset default
unset timeout
EOF


-- 
My preferred quotation of Robert Louis Stevenson is "You cannot
make an omelette without breaking eggs". Not because I like the
omelettes, but because I like the sound of eggs being broken.



More information about the freebsd-doc mailing list