Dual boot FreeBSD and Linux on a single disk

I wish to set up dual boot on a single (non-UEFI) hard drive. Should I choose GPT, rather than MBR? Should I choose GRUB2, rather than GRUB or FreeBSD's boot loader? The following write up seems to me to suggest I should:

http://ubuntuforums.org/showthread.php?t=1203580

I also looked here for a solution:

http://blog.leahhanson.us/post/freebsd-installing-and-booting.html

However, I am so far unclear about what approach I should be taking. At the moment I have FreeBSD installed and bootable with FreeBSD's boot loader. On the same disk I have Linux but have not installed GRUB for this OS (i.e. I cannot boot into Linux at present).

I think what I need to do is install and configure GRUB2 from within FreeBSD, to make the Linux partition bootable as well. My understanding is that FreeBSD's boot loader is not suitable for dual boot scenarios.

Am I on the right track with the above?
 
Just so we're clear, here:

1) "GRUB2" is GRUB. The original was deprecated years ago, and won't work with GPT.
2) GRUB cannot boot from ZFS right now, so dual-booting would require you install to UFS.
3) It shouldn't matter which OS you install GRUB from--it just ends up in its own GPT boot partition at the front of the disk either way.

Really, the easiest way to this (depending on which Linux distro you're using) is to partition your disk and install Linux first, along with GRUB; then install FreeBSD; then (from Linux) use GRUB + osprober to update your GRUB configuration. I haven't done this in a loooooong time, but when used in conjunction with osprober, GRUB should find both operating systems and configure itself automatically.
 
Just so we're clear, here:

1) "GRUB2" is GRUB. The original was deprecated years ago, and won't work with GPT.
2) GRUB cannot boot from ZFS right now, so dual-booting would require you install to UFS.
3) It shouldn't matter which OS you install GRUB from--it just ends up in its own GPT boot partition at the front of the disk either way.

Really, the easiest way to this (depending on which Linux distro you're using) is to partition your disk and install Linux first, along with GRUB; then install FreeBSD; then (from Linux) use GRUB + osprober to update your GRUB configuration. I haven't done this in a loooooong time, but when used in conjunction with osprober, GRUB should find both operating systems and configure itself automatically.

Installing Linux (in chronological time) after FreeBSD and with the step to install GRUB to the MBR, on reboot I was presented with the GRUB prompt. Following steps from the following URI, I was able to boot to Linux:

http://members.iinet.net/~herman546/p20/GRUB2 How To Boot From CLI Mode.html

From there, executing os-prober produces a screen full of apparent errors. In relation to my FreeBSD partition /dev/sda2 these are 'wrong fs-type', 'unknown Linux distribution', for example. The same happens when I execute update-grub. In both cases, mount option errors for Linux /dev/sda5 are also announced. 'Bad magic' is also mentioned.

Reboot brings up the familiar GRUB loader and I am able from there to boot into Linux. A FreeBSD option is not available.
 
Next step, create a menu, so edit /etc/grub.d/40_custom, I think:

https://help.ubuntu.com/community/Grub2 Other Os :

"A FreeBSD entry in /etc/grub.d/40_custom should look like this:"

Code:
menuentry "FreeBSD 8.0 direct" {
        insmod ufs2
        set root='(/dev/ad4,msdos1)'
        search --no-floppy --fs-uuid --set 4c0029f407b3cd1d
        kfreebsd /boot/kernel/kernel
        kfreebsd_loadenv /boot/device.hints
        kfreebsd_module /boot/splash.bmp type=splash_image_data
        set kFreeBSD.vfs.root.mountfrom=ufs:ad4s1a
}
 
Last edited:
That seems complicated.

Code:
menuentry "FreeBSD" {
set root='(hd0,3)'
kfreebsd /boot/loader
}
Usually works for me without any trouble.
I also prefer using /boot/grub2/custom.cfg
That's for Fedora, which prefers grub2 to the grub of Debian based distributions.

I also prefer to just create a custom.cfg file of my own, rather than their 40_custom.cfg, but that's just habit.
 
After booting my Linux OS, the following worked for me:

Code:
menuentry "FreeBSD" {
set root=(hd0,gpt2)
kfreebsd /boot/loader
}

Don't forget to run grub-update after editing /etc/grub.d/40_custom
 
2) GRUB cannot boot from ZFS right now, so dual-booting would require you install to UFS.

How true is this now that ZoL support has been included officially at least in Ubuntu 16.04?

I've been running Kubuntu 14.04 for years now off a ZFS pool, but using an Ext4 boot partition that holds the kernels, initrds and the grub stuff. I do use the custom grub2 provided through ZoL's Debian packages as the Ubuntu versions never detected my actual install correctly.

I hope the recipes given here will work for me, I'll be getting back a laptop from repairs and planned to use the reinstall occasion to set up a dual-boot with FreeBSD (or rather, PC-BSD O:)). Does FreeBSD have a similar design in which you can use a /boot with a more "traditional" FS and would it be wise to go for that approach immediately? I'm expecting that Linux will remain my main OS on that system until *BSD proves to work better for me, so it's kind of important that grub will see all OSes on the disk.

FWIW: an alternative approach is to set up a "USB boot dongle". That works well if 1) you don't want to touch the bootloader of your install disk (e.g. MS Window's) and 2) you're certain the other OS(es) don't touch the bootloader automatically during updates nor doing installation. That can make the initial installation a bit complex but afterwards it relatively easy. Under Linux I'd do the regular `update-grub` and then run `grub-install` to the device corresponding to my boot dongle. Without the dongle the computer would boot up with its original loader, with the dongle I'd get the grub boot menu. NB: the dongle just contained the bootloader, for the rest it was a perfectly "normal" thumb drive.
 
Back
Top