Solved Adding FreeBSD on GRUB boot menu

I am dual-booting WattOS (Debian 12) and FreeBSD 14.0 on my Thinkpad T410s on each of their own Disks

I tried os-probing to detect the FreeBSD boot partition, but it didn't work.

It seems that I have to manually add an entry on the Grub menu, but I do not know how to add it

My disks
Code:
what@WattOS-T410s:~$ sudo fdisk -l
Disk /dev/sda: 931,51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: SPCC Solid State
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: gpt
Disk identifier: 01D46D2B-FFC1-11EE-9CB8-F0DEF1246D46

Device          Start        End    Sectors  Size Type
/dev/sda1          40       1063       1024  512K FreeBSD boot
/dev/sda2        1064 1946157095 1946156032  928G FreeBSD UFS
/dev/sda3  1946157096 1953525127    7368032  3,5G FreeBSD swap


Disk /dev/sdb: 119,24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: KINGSTON SVP180S
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: 0xda0773b6

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sdb1  *         2048 231612851 231610804 110,4G 83 Linux
/dev/sdb2       231612852 250067789  18454938   8,8G 82 Linux swap / Solaris

+ my grub config file /etc/default/grub if it is needed

Code:
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=65c2645b-40ff-4e7d-ae46-b034e0d46010"
GRUB_CMDLINE_LINUX=""
GRUB_BACKGROUND="/usr/share/wattOS/unix_power.png
GRUB_DISABLE_OS_PROBER=false


I do not know if it appropriate to post this kind of help, because i need to configure this kind of thing on Linux system
 
It seems that I have to manually add an entry on the Grub menu
Try in /etc/grub/<something>-custom , I don't remember exactly the file name, it's been a while using GRUB.

[EDIT] It's /etc/grub.d/40_custom [/EDIT]
Code:
menuentry "FreeBSD" {
    root=(hd0,gpt2)
    kfreebsd /boot/loader
}

Run update-grub(8) after entry edit.
 
Try in /etc/grub/<something>-custom , I don't remember exactly the file name, it's been a while using GRUB.

[EDIT] It's /etc/grub.d/40_custom [/EDIT]
Code:
menuentry "FreeBSD" {
    root=(hd0,gpt2)
    kfreebsd /boot/loader
}

Run update-grub(8) after entry edit.

i put the the thing you gave me in /etc/grub.d/40_custom and i updated grub

when i rebooted my laptop and selected the FreeBSD option i got this error
error: disk 'hda,gpt2' not found.
Press any key to continue...
 
With grub you can drop into a "simple prompt". Then check which partitions/names are available.
Compare the output with your 40_custom.
Note : I had to use archlinux-grub instead of gentoo-grub. Because gentoo-grub did random "disk-renamings".
 
Pro tip for GRUB users, when uncertain how the menuentry should look like, boot Super Grub2 disk, choose menu entry, press "e" for edit mode, copy variables.

supergrub2-0.png supergrub2-1.png

UEFI

supergrub2-uefi-zfs-0.png supergrub2-uefi-zfs-1.png
 
With grub you can drop into a "simple prompt". Then check which partitions/names are available.
Compare the output with your 40_custom.
Note : I had to use archlinux-grub instead of gentoo-grub. Because gentoo-grub did random "disk-renamings".

Ok i went to the Grub command line and typed ls and got this output
(proc) (hd0) (hd0,msdos2) (hda0,msdos1) (hda1)

when put ls -l for the hd1 entry it says
Device hd1: No known filesystem detected - Sector size 512B - Total size 976762584KiB
 
Ok i went to the Grub command line and typed ls and got this output
Code:
 (proc) (hd0) (hd0,msdos2) (hda0,msdos1) (hda1)

when put ls -l for the hd1 entry it says
Code:
 Device hd1: No known filesystem detected - Sector size 512B - Total size 976762584KiB
Those outputs are inconsistent with the fdisk command in you opening post. FreeBSD disk sda (should be hd0 for GRUB), whereas GRUB command shows the second disk, sdb as hd0 and sda as hd1.

Doesn't the Thinkpad T410s come with a BIOS disk boot manager?

Check the disk boot order in BIOS.

Still no success, GRUB try Super Grub2 disk from post # 6.
 
This works for me on an efi booting Thinkpad with gpt partitioning.
menuentry "FreeBSD" { insmod part_gpt insmod fat set root=(hd0,gpt1) chainloader /efi/freebsd/loader.efi
In this case, FreeBSD was installed on a ZFS partition, using a tutorial on these forums by patovm04

In another multiboot scenario, I've successfully used
menuentry "FreeBSD" { set root='(hd0,3)' kfreebsd /boot/loader }
(With FreeBSD on partition 3---I forget, as it was quite awhile ago, but I think that machine had MBR partitioning.)
 
Pro tip for GRUB users, when uncertain how the menuentry should look like, boot Super Grub2 disk, choose menu entry, press "e" for edit mode, copy variables.

View attachment 18941 View attachment 18942

UEFI

View attachment 18946 View attachment 18947
Ok so i tried copying the variable FreeBSD and FreeBSD (Default boot loader)

it is exactly the same as your on your non-UEFI but instead of hd0 it is hd2 and the last string of numbers (the '6630da...' numbers) is different

it did not work

it outputs those errors:
FreeBSD
error: hd2 cannot get C/H/S values.
error: you need to load the kernel first
FreeBSD (Default boot loader)
error: hd2 cannot get C/H/S values.

i entered the ls on Super Grub2 disk cli:
(proc) (hd0) (hd0,msdos1) (hd1) (hd1,msdos2) (hd1,msdos1) (hd2) (hd2,gpt3) (hd2,gpt2) (hd2,gpt1)

it is completely different from my output on Linux grub
(proc) (hd0) (hd0,msdos2) (hd0,msdos1) (hd1)
^correct version

and i did try putting hd1 instead of hd2 on the menu entries, it didnt work
In freebsd "gpart show -p".
=> 63 250069617 ada0 MBR (119G)
63 1985 - free - (993K)
2048 231610804 ada0s1 linux-data [active] (110G)
231612852 18454938 ada0s2 linux-swap (8.8G)
250067790 1890 - free - (945K)

=> 63 250069617 diskid/DISK-X0HS10IGTJOZ MBR (119G)
63 1985 - free - (993K)
2048 231610804 diskid/DISK-X0HS10IGTJOZs1 linux-data [active] (110G)
231612852 18454938 diskid/DISK-X0HS10IGTJOZs2 linux-swap (8.8G)
250067790 1890 - free - (945K)

=> 40 1953525095 ada1 GPT (932G)
40 1024 ada1p1 freebsd-boot (512K)
1064 1946156032 ada1p2 freebsd-ufs (928G)
1946157096 7368032 ada1p3 freebsd-swap (3.5G)
1953525128 7 - free - (3.5K)
 
FreeBSD (Default boot loader)
Code:
error: hd2 cannot get C/H/S values.
Is there some BIOS setting in place for the FreeBSD disk witch could be responsible for this error message?

Does the FreeBSD disk boot at all when listed as the first disk in the disk boot order? Or boot from BIOS boot manager, if the T410s has one.
 
Personally, I've given up on trying to use GRUB to juggle booting different OSes and now use Ventoy as my boot loader.

That may with worth investigating.
 
Is there some BIOS setting in place for the FreeBSD disk witch could be responsible for this error message?
No, checked every option and there is no setting that would impact in this sort of way

The version of BIOS is 1.49 and its date is 2012-04-25. I checked for updates when I had windows 10 on it (because you can only update the bios threw windows) a week ago

Does the FreeBSD disk boot at all when listed as the first disk in the disk boot order? Or boot from BIOS boot manager, if the T410s has one.
Yes on when it is the first disk in the disk boot order and when it is selected on the BIOS boot manager

Is it time to throw my hands up and just use boot0cfg?
 
No, checked every option and there is no setting that would impact in this sort of way

I'm out of ideas what else to suggest. Searching for error: hd2 cannot get C/H/S values. I didn't find anything useful, but I didn't search that extensively either.

. https://savannah.gnu.org/bugs/?41005
. https://www.linuxfromscratch.org/lfs/troubleshooting.html

Is it time to throw my hands up and just use boot0cfg?
You could try Ventoy as balanga suggested.

Or just use the BIOS boot manager.
 
menuentry "FreeBSD" { root=(hd0,gpt2) kfreebsd /boot/loader }

The FreeBSD "root" file system disk identifier is hd0,gpt2 , not hda.
Conceptually, there is a misunderstanding about "root" It is not the location of the FreeBSD installation but the location of OS, in this case Debian, that contains Grub. This is the first stage of the boot process where a boot menu is presented and you are booting Debian. The 40-custom entry, once GRUB has been reconfigured, will provide the additional menu item of FreeBSD. In GPT booting, typically the BOOTX64.EFI (FreeBSD names this loader.efi) code will search for the partition where FreeBSD is installed and start the second stage where FreeBSD loads. Restated; Debian passes the second stage of the boot process to FreeBSD.

In a typical Debian GPT chainload install
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.
menuentry 'FreeBSD' {
         insmod part_gpt
         insmod search_fs_uuid
         insmod chain
         chainloader (hd0,gpt1)/loader.efi
}

You have to place a copy of loader.efi in the Debian directory /boot/efi/ and reconfigure grub in Debian (update-grub) in a virtual terminal (ctl-alt-F3).
 
Personally, I've given up on trying to use GRUB to juggle booting different OSes and now use Ventoy as my boot loader.

That may with worth investigating.
I really do not want to spend a USB, my limited USB slot and a lot of time understanding this program too
Conceptually, there is a misunderstanding about "root" It is not the location of the FreeBSD installation but the location of OS, in this case Debian, that contains Grub. This is the first stage of the boot process where a boot menu is presented and you are booting Debian. The 40-custom entry, once GRUB has been reconfigured, will provide the additional menu item of FreeBSD. In GPT booting, typically the BOOTX64.EFI (FreeBSD names this loader.efi) code will search for the partition where FreeBSD is installed and start the second stage where FreeBSD loads. Restated; Debian passes the second stage of the boot process to FreeBSD.

In a typical Debian GPT chainload install
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.
menuentry 'FreeBSD' {
         insmod part_gpt
         insmod search_fs_uuid
         insmod chain
         chainloader (hd0,gpt1)/loader.efi
}

You have to place a copy of loader.efi in the Debian directory /boot/efi/ and reconfigure grub in Debian (update-grub) in a virtual terminal (ctl-alt-F3).
Don't break your head and use rEFInd instead!

This was recommended here and it works like a charm, no more grub headache! 👍
I dont have UEFI, I have BIOS-legecy


NOW I have a new problem, I wanted to configure the boot0cfg with this command boot0cfg -b /boot/boot0 ada1 and when i rebooted i could only boot to Linux drive. When i removed it with gpart bootcode -b /boot/mbr ada1 and when i rebooted it, I got a Missing Operating system error (the partitions are still intact and can be bootedfrom super grub2 disk).

LUCKILY I fix it from the first reply from this forum thread https://forums.freebsd.org/threads/missing-operating-system.66737 with the gpart bootcode -b /boot/pmbr ada1 and it boots to FreeBSD normally.
I am still committed on using boot0cfg for my FreeBSD and Linux booting.I just dont know how.

P.S
i added bootme to my first partition hoping it would solve the problem I created, but i lost the thread where it mentioned that it would help me fix my problem
=> 40 1953525095 ada1 GPT (932G)
40 1024 1 freebsd-boot [bootme] (512K)
1064 1946156032 2 freebsd-ufs (928G)
1946157096 7368032 3 freebsd-swap (3.5G)
1953525128 7 - free - (3.5K)
 
BingHelloMan

Does your computer support uefi?
Does your bios computer support to select from which disk boot?
If you can select by the bios where booting you may solve this headache.

My attempts to create a manual entry for grub was a total failure, for a short period I used the bios to decide which OS running, till I was recommend to use rEFInd.
 
Conceptually, there is a misunderstanding about "root" It is not the location of the FreeBSD installation but the location of OS, in this case Debian, that contains Grub. This is the first stage of the boot process where a boot menu is presented and you are booting Debian. The 40-custom entry, once GRUB has been reconfigured, will provide the additional menu item of FreeBSD. [...] Restated; Debian passes the second stage of the boot process to FreeBSD.
I'm afraid you are mistaken. There are several mistakes in your description of how GRUB works, unless you used a unusual GRUB installation method.

The GRUB boot loader (on BIOS or UEFI) is loaded independently of Debian or other operating systems, in fact, no operating system is needed to be booted for GRUB loader to be loaded.

In a standard GRUB installation on BIOS systems with a MBR partition scheme, the GRUB loader is installed between the MBR and the first partition. The GRUB configuration files are on the Linux partition from which GRUB was installed.

On BIOS systems with a GPT partition scheme I guess it's the same (I couldn't find any information about it), or it is installed in a separate partition called "BIOS Boot Partition" (bios-boot gpart(8)).

UEFI requires a bios-boot or ESP (efi) partition on which a grub.efi loader is stored, see GRUB manual, 4.1 Installing GRUB using grub-install.

After the GRUB loader is loaded the GRUB configuration file (grub.cfg) is read from the Linux partition and the boot menu is displayed, from which the operating system to be booted can be selected.

The "root" variable specifies the device on which the FreeBSD kernel loader is located so that GRUB can load it and transfer control of the OS boot process to this loader. There are other means besides the "root" variable to specify the location, see GRUB manual, 6.4 Multi-boot manual config. I prefer a configuration as simple as possible, see the examples below.

If the device names change often (occasionally plugged in devices), other methods of device identification should be used.

On BIOS systems, the FreeBSD loader is stored within the FreeBSD root file system, as /boot/loader. I'm taking here as example only guided FreeBSD installations, one UFS root file system, on one partition. Same with ZFS (one disk stripe).

On UEFI, FreeBSD loader.efi can be targeted on the ESP (efi) or on the system root file system.

In GPT booting, typically the BOOTX64.EFI (FreeBSD names this loader.efi) code will search for the partition where FreeBSD is installed and start the second stage where FreeBSD loads.
Likely you mean UEFI, not GPT. For GPT see above "Grub installation on BIOS"

In a typical Debian GPT chainload install
Code:
     ....  
     chainloader (hd0,gpt1)/loader.efi
You have to place a copy of loader.efi in the Debian directory /boot/efi/ and reconfigure grub in Debian (update-grub) in a virtual terminal (ctl-alt-F3).
Your device description in the example makes no sense. You are placing a copy of loader.efi under the Debian /boot/efi/ directory, but in the device description (hd0,gpt1)/loader.efi under the root of a file system ("/"). It should been (hd0,gpt1)/boot/efi/loader.efi. Or is /boot/efi a mount point for a separate partition other than that of the Debian system installation?


Examples

These are working menu entries on my systems, booting multiple FreeBSD versions with GRUB on the same disk besides Linux Mint and Artix Linux on another system:

BIOS, UFS. gpt2 is the FreeBSD (root) file system, where loader(8) is located.
Code:
menuentry "FreeBSD" {
    root=(hd0,gpt2)
    kfreebsd /boot/loader
}

BIOS, ZFS
Code:
menuentry "FreeBSD" {
   search -s -l zroot
   kfreebsd /ROOT/default/@/boot/zfsloader
}

UEFI, UFS, ZFS. gpt1 is the ESP, where loader.efi(8) is stored.
Code:
menuentry "FreeBSD" {
    root=(hd0,gpt1)
    chainloader /efi/freebsd/loader.efi
}

I don't specify loading any GRUB modules (insmod), all available modules are already loaded in a standard GRUB installation. Try lsmod at the GRUB command prompt.
 
P.Si added bootme to my first partition hoping it would solve the problem I created, but i lost the thread where it mentioned that it would help me fix my problem
First, you placed the "bootme" attribue on the wrong partition. freebsd-boot is the partition storing the FreeBSD boot code (/boot/gptboot). freebsd-ufs would be the correct partition

Second, bootme doesn't have an effect here.

Why not use the laptops BIOS disk boot manager. I do it all the time on a ThinkPad E15.

Regarding GRUB error message (error: hd2 cannot get C/H/S values.), you could ask about it on GRUB mailing list, or, if you don't want to register on WattOS Discord support channel, on Debian user support.
 
Why not use the laptops BIOS disk boot manager.
Maybe you are right, I was just hoping that I would have an easier and prettier FreeBSD/Linux booting experience with GRUB so I can easily hop around both of those OSes. But it looks like the problem is bigger and weirder then I thought.

Sadly for what I know I can't set the BIOS boot to put up when I turn on my computer without pressing F12, so BIOS boot manager isn't the prettiest solution like grub.

I am gonna try figure out the original problem when I have more time on my hands.
 
The GRUB boot loader (on BIOS or UEFI) is loaded independently of Debian or other operating systems, in fact, no operating system is needed to be booted for GRUB loader to be loaded.
I beg to differ. In a typical Debian install, /dev/sda1 is created and fat(fat32) partitioned by Debian. Debian creates and hosts the /etc/fstab entry and the supporting configuration files in /etc/grub.d/. I've never tried it, but potentially, one could create a mount point in OpenBSD/FreeBSD and mount the slice containing /boot/efi.

My system dual-booting Debian Bookworm
Code:
***@******:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda3 during installation
UUID=aa85a939-320a-4adb-8401-dbd19c956860 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=CFAC-8455  /boot/efi       vfat    umask=0077      0       1
# swap was on /dev/sda2 during installation
UUID=3394335a-1b41-4cf5-aa76-dbe1bb7261fa none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0


and OpenBSD 7.5
Code:
******$ cat /etc/fstab
a91b3d70266d800c.b none swap sw
a91b3d70266d800c.a / ffs rw 1 1
a91b3d70266d800c.n /home ffs rw,nodev,nosuid 1 2
a91b3d70266d800c.d /tmp ffs rw,nodev,nosuid 1 2
a91b3d70266d800c.f /usr ffs rw,nodev 1 2
a91b3d70266d800c.g /usr/X11R6 ffs rw,nodev 1 2
a91b3d70266d800c.h /usr/local ffs rw,wxallowed,nodev 1 2
a91b3d70266d800c.m /usr/obj ffs rw,nodev,nosuid 1 2
a91b3d70266d800c.l /usr/src ffs rw,nodev,nosuid 1 2
a91b3d70266d800c.e /var ffs rw,nodev,nosuid 1 2

Debian's fstab has the /boot/efi partition and OpenBSD's fstab does not.
 
Back
Top