Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

TIP: Dual Booting Debian and FreeBSD

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
kedaha
Posts: 3521
Joined: 2008-05-24 12:26
Has thanked: 33 times
Been thanked: 77 times

TIP: Dual Booting Debian and FreeBSD

#1 Post by kedaha »

Just a note which may help someone with a similar setup who wishes to boot freeBSD from their Debian grub menu.
With two SATA disks on a desktop computer:
sda
sdb
(listed in grub as hd0 and hd1 respectively), each with several partiions.
The first, sda, which still has Windows on it, is for Debian stable.
The second, sdb is only for FreeBSD 13.0 (Filesystem: zfs).
I was able to figure out what to add to my grub menu from a post here after I found that the configuration for a previous installation of FreeBSD 12.0, which I posted at viewtopic.php?f=3&t=142819, didn't work.
I edited /etc/grub.d/40_custom to add a custom menu entry for FreeBSD so that it looks like this:
[Edited to remove insmod zfs, as commented below by p.H)

Code: Select all

#!/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 13.0" {
set root='(hd1)'
chainloader +1
}
I then ran

Code: Select all

# update-grub
And can now select and boot FreeBSD if I wish.
Last edited by kedaha on 2022-03-03 22:38, edited 1 time in total.
DebianStable

Code: Select all

$ vrms

No non-free or contrib packages installed on debian!  rms would be proud.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: TIP: Dual Booting Debian and FreeBSD

#2 Post by p.H »

Remarks :
1) This does not work only for FreeBSD but also for any OS which installed a boot loader in the boot sector of any disk or partition.
2) Chainloading a BIOS boot sector does not require any filesystem support, so insmod zfs is not necessary.
3) Beware if you add a third disk (or even USB drive), the FreeBSD disk may become hd2.
4) Don't os-prober and update-grub detect and add FreeBSD automatically ?

kedaha
Posts: 3521
Joined: 2008-05-24 12:26
Has thanked: 33 times
Been thanked: 77 times

Re: TIP: Dual Booting Debian and FreeBSD

#3 Post by kedaha »

Thanks p.H for your remarks.
p.H wrote: 2022-03-02 12:17 1) This does not work only for FreeBSD but also for any OS which installed a boot loader in the boot sector of any disk or partition.
2) Chainloading a BIOS boot sector does not require any filesystem support, so insmod zfs is not necessary.
I've removed insmod zfs, seeing that it's unnecessary.
p.H wrote: 3) Beware if you add a third disk (or even USB drive), the FreeBSD disk may become hd2.
OK, I'll watch out for that.
p.H wrote:4) Don't os-prober and update-grub detect and add FreeBSD automatically ?
Having read a post over at the FreeBSD forums at how-to-write-freebsd-boot-loader-into-grub-cfg.81336, I expected os-prober to at least detect FreeBSD but it only finds Windows 10.
I don't know if this might have something to do with it but with UEFI disabled in the BIOS, I only have four grub packages: grub-pc-bin, grub2-common, grub-common and grub-pc.
DebianStable

Code: Select all

$ vrms

No non-free or contrib packages installed on debian!  rms would be proud.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: TIP: Dual Booting Debian and FreeBSD

#4 Post by p.H »

kedaha wrote: 2022-03-03 00:10 Having read a post over at the FreeBSD forums at how-to-write-freebsd-boot-loader-into-grub-cfg.81336, I expected os-prober to at least detect FreeBSD
It appears that os-prober does not include any script to detect any *BSD. Also in that post it looks like FreeBSD is detected as a Linux system.

Code: Select all

/dev/sdb2:FreeBSD 13.0-RELEASE:FreeBSD:linux
Not knowing anything about *BSD, I cannot tell if this is expected or not.
kedaha wrote: 2022-03-03 00:10 I don't know if this might have something to do with it but with UEFI disabled in the BIOS, I only have four grub packages: grub-pc-bin, grub2-common, grub-common and grub-pc.
These are the only GRUB packages used for BIOS/legacy boot.

kedaha
Posts: 3521
Joined: 2008-05-24 12:26
Has thanked: 33 times
Been thanked: 77 times

Re: TIP: Dual Booting Debian and FreeBSD

#5 Post by kedaha »

p.H wrote: 2022-03-06 08:59
kedaha wrote: 2022-03-03 00:10 Having read a post over at the FreeBSD forums at how-to-write-freebsd-boot-loader-into-grub-cfg.81336, I expected os-prober to at least detect FreeBSD
It appears that os-prober does not include any script to detect any *BSD. Also in that post it looks like FreeBSD is detected as a Linux system.

Code: Select all

/dev/sdb2:FreeBSD 13.0-RELEASE:FreeBSD:linux
Not knowing anything about *BSD, I cannot tell if this is expected or not.
If anyone installs FreeBSD with UEFI I'd be interested to know if it also gets detected as linux.
I got interested in FreeBSD when Debian GNU/kFreeBSD was released with squeeze and wheezy as a "technology preview and the first non-Linux port" and posted about it here back in 2013. I'm particulary interested in FreeBSD because, among other reasons given here like no systemd, OSS is the default sound system, which I much prefer to ALSA with Pulseaudio. Since kFreeBSD seems to have pretty well petered out in Debian and, just as I feared, development of OSS4 in Debian Linux has ground to a standstill long ago as I posted in this topic, I came to the conclusion that the only way to have the best of both worlds was to dual boot them.
DebianStable

Code: Select all

$ vrms

No non-free or contrib packages installed on debian!  rms would be proud.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: TIP: Dual Booting Debian and FreeBSD

#6 Post by p.H »

kedaha wrote: 2022-03-07 10:44 If anyone installs FreeBSD with UEFI I'd be interested to know if it also gets detected as linux.
FWIW Linux detection by os-prober does not depend on the boot mode, it is based on the presence and/or contents of some system files.

Post Reply