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

    Messages:
    36
    Likes Received:
    0
    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:
    pkg_add-r grub2
    
    Prepares the directory structure
    Code:
    cd /boot
    mkdir grub
    cd grub
    touch grub.cfg 
    
    For grub.cfg adds the following entry
    Code:
    set timeout = 3
    set default = "0"
    menuentry "FreeBSD 8 Server" {
    insmod ufs2
         set root = (hd0, 1)
    chainloader 1
    }
    
    Code:
    set root = (hd0, 1)
    
    This is for disk 1, and freebsd FreeBSD installed on the first slice.

    Code:
    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:
    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.
    Code:
    sysctl kern.geom.debugflags = 16
    
    And that's it. It remains to install grub
    Code:
    grub-install /dev/ad0
    
    If a message pops up like this, everything is ok
    Code:
    freebsdserver # grub-install /dev/ad0
    Installation finished. No error reported.
    freebsdserver #
    
    After installation, it looks like this

    [​IMG]

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

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,201
    Likes Received:
    14
    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.)