1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to install grub2 on FreeBSD

Discussion in 'Howtos and FAQs (Moderated)' started by Yampress, Dec 20, 2011.

  1. Yampress

    Yampress New Member

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

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

    pkg_add-r grub2

    Prepares the directory structure
    cd /boot
    mkdir grub
    cd grub
    touch grub.cfg 

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

    set root = (hd0, 1)

    This is for disk 1, and freebsd FreeBSD installed on the first slice.

    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

    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 freebsd FreeBSD
    If we do not, freebsd FreeBSD will not be able to install grub in the MBR.
    sysctl kern.geom.debugflags = 16

    And that's it. It remains to install grub
    grub-install /dev/ad0

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

    After installation, it looks like this


    Now you can add other systems. windows, linux and bsd other configuration file.
    markfisher and wblock@ thanked for this.
  2. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Thanks Received:
    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.)