How to install grub2 on FreeBSD

Would you like to share some of your solutions for certain problems? Tips or tricks? Post here. All new topics are automatically moderated.

How to install grub2 on FreeBSD

Postby Yampress » 20 Dec 2011, 18:43

How to install grub2, which may be useful to run multiple systems described below. Of course, previously tested by me like everyone my faq.


THE WORKS
All I do the following as root.
Install grub 2 first. I do it with packages

Code: Select all
pkg_add-r grub2


Prepares the directory structure
Code: Select all
cd /boot
mkdir grub
cd grub
touch grub.cfg


For grub.cfg adds the following entry
Code: Select all
set timeout = 3
set default = "0"
menuentry "FreeBSD 8 Server" {
insmod ufs2
     set root = (hd0, 1)
chainloader 1
}


Code: Select all
set root = (hd0, 1)

This is for disk 1, and [del]freebsd[/del] FreeBSD installed on the first slice.

Code: Select all
set root = (hd0, 3)

This is for disk 1, and freebsd installed on the third slice.
And just for themselves similarly change the parameters ...

Now copies the files to the right place to /boot/grub

Code: Select all
cp-Rf /usr/local/lib/grub/i386-pc /boot/grub


Before you install grub in the MBR disk must be allowed to overwrite the MBR [del]freebsd[/del] FreeBSD
If we do not, [del]freebsd[/del] FreeBSD will not be able to install grub in the MBR.
Code: Select all
sysctl kern.geom.debugflags = 16

And that's it. It remains to install grub
Code: Select all
grub-install /dev/ad0


If a message pops up like this, everything is ok
Code: Select all
freebsdserver # grub-install /dev/ad0
Installation finished. No error reported.
freebsdserver #


After installation, it looks like this

Image

Now you can add other systems. windows, linux and bsd other configuration file.
User avatar
Yampress
Junior Member
 
Posts: 36
Joined: 08 Aug 2010, 11:37
Location: PL

Postby wblock@ » 20 Dec 2011, 20:26

Yampress wrote:Before you install grub in the MBR disk must be allowed to overwrite the MBR [del]freebsd[/del] FreeBSD
If we do not, [del]freebsd[/del] FreeBSD will not be able to install grub in the MBR.
Code: Select all
sysctl kern.geom.debugflags = 16


That setting actually allows writes to areas of the disk that are in use by geom. Typically that's for the very special case of writing to an important block of a mounted partition. The MBR should not need that, and in fact it should be very rare to need that sysctl at all.

(Some of the misunderstanding is my fault, since I didn't understand it and promoted the misuse in a couple of articles. Sorry about that.)
User avatar
wblock@
Old Fart
 
Posts: 10204
Joined: 07 Sep 2009, 23:23
Location: Milky Way galaxy


Return to Howtos & FAQs (Moderated)

Who is online

Users browsing this forum: No registered users and 0 guests