Add FreeBsd 12.3 to Grub2 bootloader?

hi, I have a pc with a triple-boot configuration: HDD #1 has windows7/FreeBSD12 installed as a dual boot, and SSD #2 has Devuan installed. I used Grub2 from Devuan to load the three OS.

Over the weekend, I reinstalled windows 7 on Hdd, this of course broke the existing bootloader and boot menu, So I recreated bootloader with Devuan netinstaller USB. I can boot into both windows and linux but FreeBSD is missing from the boot menu.

Below is the disk partition configuration, FreeBSD is on /dev/sda2:

Code:
erdos@htpc-devuan:~/Downloads/m64py-0.2.5$ sudo fdisk -l
[sudo] password for erdos:
Disk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: WDC WD5000AAKS-6
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1549f232

 Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 204812287 204810240  97.7G  7 HPFS/NTFS/exFAT
/dev/sda2       204812685 309670262 104857578    50G a5 FreeBSD
/dev/sda3       309861721 953151487 643289767 306.7G  f W95 Ext'd (LBA)
/dev/sda4       953152515 976768064  23615550  11.3G  7 HPFS/NTFS/exFAT
/dev/sda5       309861784 953151487 643289704 306.7G  7 HPFS/NTFS/exFAT

 Partition table entries are not in disk order.

 Disk /dev/sdb: 55.9 GiB, 60022480896 bytes, 117231408 sectors
Disk model: Corsair Force LS
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x287905c2

 Device     Boot     Start       End  Sectors  Size Id Type
/dev/sdb1  *         2048  39063551 39061504 18.6G 83 Linux
/dev/sdb2        39065598 117229567 78163970 37.3G  5 Extended
/dev/sdb5        39065600 113283071 74217472 35.4G 83 Linux
/dev/sdb6       113285120 117229567  3944448  1.9G 82 Linux swap / Solaris

How do I add FreeBSD to the Grub bootloader?
 
Adjust disk and partition numbers as needed.
Code:
menuentry "FreeBSD hd0,2" {
    insmod ufs2
    set root=(hd0,2)
    kfreebsd /boot/loader
}

In theory grub-install should pick up on a FreeBSD partition and do this automatically, but it seems to be flaky.
 
this is what I use 40_custom

Code:
#!/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.
#slack current

menuentry "#1 FreeBSD 13.1" {
      insmod ufs2
      root=(hd1,gpt5)
      chainloader /boot/loader.efi
}
menuentry "#2 FreeBSD 13.2 RCx" {
    insmod ufs2
    root=(hd0,gpt6)
    chainloader /boot/loader.efi
}
hdX is disk number zero based naming scheme then partition number
 
Instead of fiddling around with grub, just use a proper EFI bootmanager - e.g. rEFInd: https://www.rodsbooks.com/refind/
yeah that works too, But i personally don't like it because it picks up everything and then I have to figure out what is what and it does not display the icon of the distro properly . it gives grub and efi and it still needs lots of improvement ( on customization options mostly), but it does work.

I went back to grub its simple
 
Thank you so much, guys!
I added the following to 40_custom, works out perfectly!

Code:
menuentry "FreeBSD hd1,2" {
    insmod ufs2
    set root=(hd1,2)
    kfreebsd /boot/loader
}
 
Back
Top