Configure Ubuntu Linux GRUB to load FreeBSD

Recently my friend emailed me an interesting scenario. He installed FreeBSD 6.0 / 7.0 in the first primary partition (10G). One day he installed Ubuntu Linux. He can boot into Linux but not able to boot into FreeBSD. Now, my friend wanted to boot both FreeBSD and Ubuntu Linux via Grub boot loader.

It is not that hard to configure grub to boot FreeBSD. You just need to add following three lines to grub configuration file (/boot/grub/menu.lst). Boot into Ubuntu Linux and use text editor to edit the file /boot/grub/menu.lst ( Red hat and friends [ Fedora / CentOS ] try /etc/grub.conf file) :
$ gksudo gedit /boot/grub/menu.lst
OR
$ gksudo vi /boot/grub/menu.lst
Append FreeBSD boot Configuration:

title  FreeBSD 7.0 root   (hd0,a) kernel /boot/loader

Save and close the file. To see changes or to boot into FreeBSD reboot Ubuntu Linux box.
Where,

  • title FreeBSD 7.0 : Start a new boot entry. User always sees this title and hit enter key to boot os.
  • root (hd0,a) : Actual part is to select the correct root partition. The root option set the current root device to the device, then attempt to mount it to get the partition size. In above example – hd0 is your first hard disk i.e. hda in Linux. In grub hda is hd0. Likewise your first, second partition on the first hard disk รขโ‚ฌโ€œ hda1, hda2, becomes hd0,0 hd0,1 in Grub. In short, you are asking to use first hard first partition (remember FreeBSD use a,b,c names to represent partition names). If you have installed FreeBSD on third partition then you need to use following root statement:
    root (hd0,2,a)
  • kernel /boot/loader : Use to load the primary boot image. FreeBSD use /boot/loader to load rest of kernel and os.

๐Ÿฅบ Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Vivek Gite is an expert IT Consultant with over 25 years of experience, specializing in Linux and open source solutions. He writes about Linux, macOS, Unix, IT, programming, infosec, and open source. Follow his work via RSS feed or email newsletter.

Category List of Unix and Linux commands
AnsibleCheck version Fedora FreeBSD Linux Ubuntu 18.04 Ubuntu macOS
Archivingz commands
Backup ManagementDebian/Ubuntu FreeBSD RHEL
Database ServerBackup MySQL server MariaDB Galera cluster MariaDB TLS/SSL MariaDB replication MySQL Server MySQL remote access
Download managerswget
Driver ManagementLinux Nvidia driver lsmod
Documentationhelp mandb man pinfo
Disk Managementdf duf ncdu pydf
File Managementcat cp less mkdir more tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04 Ubuntu 24.04
KVM VirtualizationCentOS/RHEL 7 CentOS/RHEL 8 Debian 9/10/11 Ubuntu 20.04
Linux Desktop appsChrome Chromium GIMP Skype Spotify VLC 3
LXDBackups CentOS/RHEL Debian 11 Fedora Mount dir Ubuntu 20.04 Ubuntu 22.04
Modern utilitiesbat exa
Network ManagementMonitoring tools Network services RHEL static IP Restart network interface nmcli
Network UtilitiesNetHogs dig host ip nmap ping
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 11 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Power Managementupower
Package Managerapk apt-get apt yum
Processes Managementbg chroot cron disown fg glances gtop iotop jobs killall kill pidof pstree pwdx time vtop
Searchingag egrep grep whereis which
Shell builtinscompgen echo printf
System Managementreboot shutdown
Terminal/sshsshpass tty
Text processingcut rev
Text Editor6 Text editors Save and exit vim
User Environmentexit who
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami w
User Management/etc/group /etc/passwd /etc/shadow chsh
Web ServerApache Let's Encrypt certificate Lighttpd Nginx Security Nginx
WireGuard VPNAlpine Amazon Linux CentOS 8 Debian 10 Firewall Ubuntu 20.04 qrencode
14 comments… add one
  • seaman Mar 17, 2006 @ 23:28

    If it does not want to boot you can put something like this:

    title FreeBSD
    rootnoverify (hd0,0)
    makeactive
    chainloader +1

    it realy works

  • DJ Tux Mar 18, 2006 @ 1:44

    GRUB loads the kernel directly and FreeBSD’s bootstrap interface sometimes changes heavily so GRUB can’t guarantee to pass kernel parameters correctly. Thus loading it via very flexible loader i.e. /boot/loader is highly recommend.

    @seaman,
    Your method is good when unsupported operating systems needs booting via GRUB. But for FreeBSD /boot/loader is highly recommend.

    Cheers,

    DJ Tux

  • johan Jan 3, 2007 @ 13:24

    Hey,
    I dont really understand, I got ubuntu and windowsxp,, now when I start my computer I want to be able co choose one of these, what shoud I put to choose windows xp?
    have to ask so I dont do anything wrong,
    Thank you,
    Johan

  • ๐Ÿ‘ฎ๐Ÿ›ก๏ธ Vivek Gite (Author and Admin) nixCraft Jan 3, 2007 @ 13:26

    johan,

    Do you see Windows XP as boot option? If so just select and enter. If you don’t see an option you need to edit grub.conf

  • Matrixium Aug 20, 2007 @ 18:33

    Hi,
    I just install ubuntu on top of window xp. I can boot into ubuntu, but I can not boot into window xp.
    when I start my computer I was able to choose window xp as one of the choices to boot. But then the windows xp went to a autocheck,and autochecks fails. then the system restarts itself.
    can you help to solve the problem?

    Thank you

  • Marco van de Voort Oct 21, 2007 @ 14:04

    Note that partition (label) “c” is special and designates the whole disc.

    P.s. it is kind of confronting having to type “linux” as antispam word on a FreeBSD topic ๐Ÿ™‚

  • cfchris6 Apr 1, 2008 @ 20:46

    /boot/loader did not work for me, I think that is mainly because GRUB is not able to handle the disklabels of BSD correctly because /boot/loader may be in ad0s1a but GRUB looks just in ad0s1, so GRUB does not find anything.

    root(hd?,?)
    makeactive
    chainloader +1

    works perfectly and gives all the possibilitiys as a bootloader directly installed on MBR.

  • John Marino Apr 26, 2008 @ 0:18

    Thanks for this article.

    I was not amused tonight. I have FreeBSD on my primary partition of my primary disk. A few months ago I left 24GB free reserved for a Linux testbed and installed Ubuntu 8.04 tonight. Much to my anger, it wiped out my existing bootloader and I couldn’t get back to my primary OS.

    This article pointed me in the right direction — true I am now using grub instead of the freeBSD bootloader but at least I can get to FreeBSD now.

  • talishte Jul 8, 2008 @ 17:01

    Thanks U

  • Ramanathan Sep 9, 2008 @ 10:56

    To enable FreeBSD 7 in Ubuntu Gibbon,
    Appending this following lines helped me.

    title FreeBSD 7
    rootnoverify (hd0,0)
    makeactive
    chainloader +1

    Thanks

  • Ramanathan Sep 9, 2008 @ 10:58

    ****************************************************
    To enable FreeBSD 7 in Ubuntu Gibbon,
    Appending this following lines in /boot/grub/menu.lst helped me.

    title FreeBSD 7
    rootnoverify (hd0,0)
    makeactive
    chainloader +1

    Thanks

    *************************************************

  • Ramanathan Sep 9, 2008 @ 11:20

    ————————————————–
    ****************************************************
    Partition Detail
    —————-
    FreeBSD is installed in the First partition of the primary IDE hard disc. Ubuntu is in second partition.

    I tried the first option given in this website.
    It too worked.

    The following lines are appended.

    title FreeBSD 7
    root (hd0,0,a)
    kernel /boot/loader

    Thanks Again. ๐Ÿ™‚

    *************************************************

  • Dheeraj Suthar Mar 27, 2010 @ 16:18

    Thanks a lot !!
    It saved my day.
    However I also used this article to restore my filesystem:
    http://neosmart.net/forums/showthread.php?t=1823

  • oriantho Nov 28, 2010 @ 23:56

    salut !! i have blowed my system and i ive tryed to restore with alive cd 1010 ..nothing happen,THEN with a 2009 version ,better but when i start i have a strange console saying :shgrub or rescue grub ,mostly i cant send any command ,the pianno don’t play all the letters proppely ..my question :do we have something to load before the live cd to make it work? a grub?linux ? if yes ,how do i empty ALL on that computer to be sure there is nothing at all before the new setting THANKS from France and please to help you for some kind of help i can O.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.