Add FreeBSD to GRUB2 boot menu

Here is mine:

menuentry "FreeBSD" --class freebsd --class bsd --class os {
 insmod ufs2
 insmod bsd
 set root=(hd0,1)
 kfreebsd /boot/kernel/kernel
 kfreebsd_loadenv /boot/device.hints
 set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada0s1a
 set kFreeBSD.vfs.root.mountfrom.options=rw
 set kFreeBSD.hw.psm.synaptics_support=1
}

My Goal was to: Boot FreeBSD 10 from Grub2 by editing 40_custom in /etc/grub.d

My Setup: FreeBSD10 is on the fifth hdd of my system (/dev/sde under Linux, so hd4 for Grub2. Remember that under Grub2 hd starts from hd0 for drives, and partitions from 1 and on, not zero). The root partition is the second one (/dev/sde2) as I've used FreeBSD's Guided partitioning (use entire disk) while installing (simplest). Recalling, that is: set root='(hd4,2)' for the fifth hdd and the 2nd partition.

info: (chainloader +1 is actually not required ! The following brings me directly to FreeBSDs Bootloader).

To summarize a little: you just got to adapt set root=(x,x), nothing more is needed. If you want to boot the kernel directly, things get a little more complex than the entry below.

menuentry "FreeBSD 10.0" {
    insmod part_gpt
    set root='(hd4,2)'
    kfreebsd /boot/loader
}

I was a bit disappointed by os-prober which just found 'Unknown linux distribution on /dev/sde2'

ps: don't forget 'update-grub' afterwards and Taddaa (hopefully). :) If somebody succeed, throw me a msg, i would be happy to hear from you !


Do it in this order:

  1. Edit your /etc/grub.d/40_custom and add uzsolt's directives. Add the directive at the end of the file. Don't delete anything that is in there.

  2. Make sure 40_custom is executable. If not then chmod u+x 40_custom.

  3. Now do this to write the changes to grub.cfg.

    grub2-install /dev/sda 
    os-prober 
    grub2-mkconfig -o /boot/grub/grub.cfg
    
  4. Tada! Reboot now; you should have FreeBSD in your OS list in GRUB menu.

To have access to your UFS partition slice you should do the following:

  1. Edit your kernel configuration to add UFS filesystem and UFS label.

  2. Then make && make_modules your kernel.

  3. Install the UFS filesystem software.

  4. Mount your UFS Slice under your Linux:

    sudo mkdir /mnt/freebsd && sudo mount -r -t ufs -o ufstype=ufs2 /dev/sda1 /mnt/freebsd
    

Tags:

Freebsd

Grub2