I have Gentoo x64 installed with Grub2 on my MBR drive. Today I installed FreeBSD x64 9.2. Now I'm in Gentoo and trying to add FreeBSD to grub2 menu list.

grub2-install /dev/sda
grub2-mkconfig -o /boot/grub2/grub.cfg

I did the above on Gentoo and it didn't find FreeBSD. The FreeBSD nested partition is on sda1 and contains freebsd-ufs and freebsd-swap partitions.

How could I add FreeBSD to grub2?


7 Answers 7


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
  • 1
    did you generate it with os-prober or you did it yourself. also which file did that directive go in?
    – r004
    Jan 14, 2014 at 11:08
  • does the sda1 translate to hd0,1 ? is it true that grub2 start from 1 not 0?
    – r004
    Jan 14, 2014 at 11:14
  • 2
    No, this /isn't auto-generated. I've wrote it into /etc/grub.d/40_custom, check this: wiki.archlinux.org/index.php/…
    – uzsolt
    Jan 14, 2014 at 11:35
  • 1
    Yes, (hd0,1) is sda1.
    – uzsolt
    Jan 14, 2014 at 11:35
  • the freebsd is in the /dev/sda1 but the sda1 is a partition slice (according to bsd terminology); and it contains a / and swap partition. How should I precede then?
    – r004
    Jan 18, 2014 at 21:13

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 !

  • good for gpt partition table
    – r004
    Sep 19, 2014 at 9:11
  • What is insmod part_gpt ?
    – user254419
    Dec 7, 2017 at 17:16
  • insmod - module loader. part_gpt - provides support for GPT (GUID Partition Table) partitions and partitioning tables. Not sure this line is necessary. May 26, 2021 at 4:59
  • kfreebsd only works when the bsd Grub module is loaded.
    – ckujau
    Aug 24, 2023 at 11:31

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 
    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
  • Both os-prober and grub-mkconfig -o /boot/grub/grub.cfg show that there is an unknown Linux distribution on /dev/sda16. Now FreeBSD is not Linux and I followed these steps exactly May 27, 2020 at 10:50

According to this site:

  1. Boot Linux.
  2. Create a /boot/grub2/custom.cfg file.
  3. Add these lines to the created file:

    menuentry "FreeBSD" {
    set root='(hd0,3)'
    kfreebsd /boot/loader

    where hd0,3 means this is the first hard drive and FreeBSD is on its third partition (since disks are numbered from 0 and partitions are numbered from 1). Probably you'll have to adjust those numbers. One way to find out what your disks are is to run fdisk -l.

  4. Run grub2-mkconfig -o /boot/grub2/grub.cfg.

Remember that your commands might be slightly different. grub2-mkconfig might be grub-mkconfig and so on (this was my case on BunsenLabs Linux).

Mind that I was using FreeBSD with UFS instead of ZFS on this machine. The presented solution does not work for ZFS-based installations from what I've heard.


The Arch Linux wiki has a very nice explanation for the same. It guides the normal way i.e. direct OS loading as well as chainloading.

However, one must not forget to issue sudo grub-mkconfig -o /boot/grub/grub.cfg to commit changes.


Currently on Ubuntu 20.04 and FreeBSD 12.x below thing works.

/etc/grub.d/40_custom file in Ubuntu, add the following:-

root@a44h-ubuntu:/home/xxxxxxx# more /etc/grub.d/40_custom
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "FreeBSD" {
        insmod ufs2   
        chainloader (hd0,msdos1)/boot/boot 
        #does not work for me
        #set root=(hd0,1)     #does not work for me
        #kfreebsd /boot/boot0 #does not work for me
        #chainloader +1       #does not work for me

Then turn on the boot manager menu at boot up, change :-


then do:

root@a44h-ubuntu:/home/xxxxxxx# update-grub

Nothing needs to be done in FreeBSD.

The hd0 is first hard disk and msdos1 is s1.


the config for my particular setup the setup (using UEFI and GBT) in /etc/grub.d/40_custom is

menuentry "FreeBSD" {
        insmod ufs2   
        chainloader (hd0,7)/boot/loader.efi 

for your setup you might need to modify the following: hd0 might need to be changed if you have multiple disks, the "7" is the partition number(if using MBR then add msdos before the number such as "msdos7"),and if you are using BIOS change "loader.efi" to "loader"(I have not tested this). I am not sure what to do if you are not on ufs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .