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 os-prober 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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
}
Method 2
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 !
Method 3
Do it in this order:
-
Edit your
/etc/grub.d/40_customand add uzsolt’s directives. Add the directive at the end of the file. Don’t delete anything that is in there. -
Make sure
40_customis executable. If not thenchmod u+x 40_custom. -
Now do this to write the changes to
grub.cfg.grub2-install /dev/sda os-prober grub2-mkconfig -o /boot/grub/grub.cfg
- 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:
-
Edit your kernel configuration to add
UFS filesystemandUFS label. -
Then
make && make_modulesyour kernel. - Install the UFS filesystem software.
-
Mount your UFS Slice under your Linux:
sudo mkdir /mnt/freebsd && sudo mount -r -t ufs -o ufstype=ufs2 /dev/sda1 /mnt/freebsd
Method 4
According to this site:
- Boot Linux.
- Create a
/boot/grub2/custom.cfgfile. -
Add these lines to the created file:
menuentry "FreeBSD" { set root='(hd0,3)' kfreebsd /boot/loader }where
hd0,3means 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 runfdisk -l. -
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.
Method 5
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.
Method 6
Currently on Ubuntu 20.04 and FreeBSD 12.x below thing works.
/etc/grub.d/40_custom file in Ubuntu, add the following:-
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0d7f6262794d6c39396520786f78637978">[email protected]</a>:/home/xxxxxxx# more /etc/grub.d/40_custom
#!/bin/sh
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 :-
#GRUB_TIMEOUT_STYLE="hidden" GRUB_TIMEOUT_STYLE="menu"
then do:
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9abb6b6ad99b8ededb1f4acbbacb7adac">[email protected]</a>:/home/xxxxxxx# update-grub
Nothing needs to be done in FreeBSD.
The hd0 is first hard disk and msdos1 is s1.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0