Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Jun 2021 11:50:03 -0700
From:      Navdeep Parhar <nparhar@gmail.com>
To:        "Thomas D. Dean" <tomdean@wavecable.com>, freebsd-questions@freebsd.org
Subject:   Re: Grub Entry to Boot FreeBSD
Message-ID:  <42f7d662-3454-cae4-2141-f8b18dd543df@gmail.com>
In-Reply-To: <f24f6c17-0b81-b341-6f5b-d7f7f44671c4@wavecable.com>
References:  <61cf5297-d289-9356-62b1-feb577050d6e@wavecable.com> <f24f6c17-0b81-b341-6f5b-d7f7f44671c4@wavecable.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 6/2/21 10:43 AM, Thomas D. Dean wrote:
> On 6/1/21 9:10 PM, Thomas D. Dean wrote:
>> I have a remote system with Linux and FreeBSD.=C2=A0 I want to select =
the=20
>> next boot OS at runtime and boot it.
>>
>> I can do that with
>> =C2=A0=C2=A0=C2=A0 grub-set-default 'Ubuntu'
>> =C2=A0=C2=A0=C2=A0 -or-
>> =C2=A0=C2=A0=C2=A0 grub-set-default 'FreeBSD'
>> and reboot.
>>
>> My problem is with the FreeBSD entry.=C2=A0 How do I write the entry?
>>
>> The disks are:
>> =C2=A0=C2=A0 NAME=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MAJ:MIN RM=
=C2=A0=C2=A0 SIZE RO TYPE MOUNTPOINT
>> nvme0n1=C2=A0=C2=A0=C2=A0=C2=A0 259:0=C2=A0=C2=A0=C2=A0 0 931.5G=C2=A0=
 0 disk
>> |-nvme0n1p1 259:4=C2=A0=C2=A0=C2=A0 0=C2=A0=C2=A0 512M=C2=A0 0 part /b=
oot/efi
>> `-nvme0n1p2 259:5=C2=A0=C2=A0=C2=A0 0=C2=A0=C2=A0 931G=C2=A0 0 part /
>> nvme1n1=C2=A0=C2=A0=C2=A0=C2=A0 259:1=C2=A0=C2=A0=C2=A0 0 931.5G=C2=A0=
 0 disk
>> `-nvme1n1p1 259:3=C2=A0=C2=A0=C2=A0 0 931.5G=C2=A0 0 part
>> nvme2n1=C2=A0=C2=A0=C2=A0=C2=A0 259:2=C2=A0=C2=A0=C2=A0 0 931.5G=C2=A0=
 0 disk
>> |-nvme2n1p1 259:6=C2=A0=C2=A0=C2=A0 0=C2=A0=C2=A0 512K=C2=A0 0 part
>> |-nvme2n1p2 259:7=C2=A0=C2=A0=C2=A0 0=C2=A0=C2=A0 928G=C2=A0 0 part
>> `-nvme2n1p3 259:8=C2=A0=C2=A0=C2=A0 0=C2=A0=C2=A0 3.5G=C2=A0 0 part
>>
>> /dev/nvme0n1p2: UUID=3D"55626001-0033-445b-bd2b-0bf4766e25bb" TYPE=3D"=
ext4"
>> =C2=A0=C2=A0=C2=A0 PARTUUID=3D"2b247e80-cf2e-4be1-b6d7-61152af7132f"
>> /dev/nvme0n1p1: UUID=3D"7076-258D" TYPE=3D"vfat" PARTLABEL=3D"EFI Syst=
em
>> =C2=A0=C2=A0=C2=A0 Partition" PARTUUID=3D"16a50609-64b2-47ad-8802-c3cb=
b4be263f"
>> /dev/nvme1n1p1: UUID=3D"e26e4bf7-6e65-4fac-b2b4-f84019f70c08" TYPE=3D"=
ext4"
>> =C2=A0=C2=A0=C2=A0 PARTUUID=3D"beccec5f-01"
>> /dev/nvme2n1p1: PARTUUID=3D"3fed2b68-c26f-11eb-a073-18c04d84849a"
>> /dev/nvme2n1p2: UUID=3D"60b57d7bd4b24f00" TYPE=3D"ufs"
>> =C2=A0=C2=A0=C2=A0 PARTUUID=3D"3fed7a4f-c26f-11eb-a073-18c04d84849a"
>> /dev/nvme2n1p3: PARTUUID=3D"3fedfa22-c26f-11eb-a073-18c04d84849a"
>>
>> Device=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 Start=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 End=C2=A0=C2=
=A0=C2=A0 Sectors=C2=A0 Size Type
>> /dev/nvme2n1p1=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 40=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1063=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1=
024=C2=A0 512K FreeBSD boot
>> /dev/nvme2n1p2=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1064 1946157095 194=
6156032=C2=A0 928G FreeBSD UFS
>> /dev/nvme2n1p3 1946157096 1953525127=C2=A0=C2=A0=C2=A0 7368032=C2=A0 3=
=2E5G FreeBSD swap
>>
>> Ubuntu=C2=A0 is on nvme0n1, or, I think hd0,1 in grub terms.
>> FreeBSD is on nvme2n1, or, I think hd2,2
>>
>> But, grub thinks hd2 is just hd2 or hd2,msdos1
>>
>> I have
>> =C2=A0> cat /etc/grub.d/40_custom
>> #!/bin/sh
>> exec tail -n +3 $0
>> # This file providesan easyway toadd custom menu entries.Simply type t=
he
>> # menu entries youwant toadd after this comment.Be careful not to chan=
ge
>> # the 'exec tail' line above.
>> menuentry 'FreeBSD' {
>> =C2=A0=C2=A0 insmod ufs2
>> =C2=A0=C2=A0 set root=3D(hd2,2)
>> =C2=A0=C2=A0 chainloader /boot/loader.elf
>> }
>>
>> I tried
>> menuentry 'FreeBSD' {
>> =C2=A0=C2=A0=C2=A0=C2=A0 insmod ufs2
>> =C2=A0=C2=A0=C2=A0=C2=A0 set root=3D(hd2,1,a)
>> =C2=A0=C2=A0=C2=A0=C2=A0 search --no-floppy -fs-uuid --set=20
>> 3fed2b68-c26f-11eb-a073-18c04d84849a
>> =C2=A0=C2=A0=C2=A0=C2=A0 kfreebsd /boot/loader
>> }
>>
>> When I reboot after grub-set-default 'FreeBSD', the remote system=20
>> hangs. =C2=A0=C2=A0Grub can not find hd2.
>>
>=20
> It seems impossible to boot FreeBSD with grub.=C2=A0 In grub, I can fin=
d the=20
> Freebsd /boot directory and load some files.=C2=A0 But, it will not boo=
t.
>=20

I boot FreeBSD with grub all the time but my setup is ZFS only.  There=20
are multiple versions of FreeBSD, each installed into its own ZFS pool,=20
on the system and I use grub to select which one to boot.

My grub.cfg looks like this and works with BIOS and UEFI:

---
insmod part_msdos
insmod part_gpt
insmod chain
insmod fat
insmod bsd
insmod zfs
load_env

menuentry "FreeBSD 13" {
         search -s -l bsd13
         kfreebsd -D /@/boot/zfsloader
         set default=3D"${chosen}"
         save_env default
}

menuentry "FreeBSD 12" {
         search -s -l bsd12
         kfreebsd -D /@/boot/zfsloader
         set default=3D"${chosen}"
         save_env default
}

and so on...
---

The most complicated FreeBSD entry that I can find in all the grub.cfg=20
files that I have is this old one (BIOS only).  It boots the system from =

an mfsbsd ISO:

menuentry "mfsBSD 11.2-RELEASE" {
         loopback loop /boot/mfsbsd-11.2-RELEASE-amd64.iso
         kfreebsd -D (loop)/boot/kernel/kernel.gz
         kfreebsd_loadenv (loop)/boot/device.hints
         kfreebsd_module (loop)/boot/kernel/ahci.ko
         kfreebsd_module (loop)/mfsroot.gz type=3Dmfs_root
         set kFreeBSD.console=3D"comconsole,vidconsole"
         set kFreeBSD.comconsole_speed=3D"115200"
         set kFreeBSD.vfs.root.mountfrom=3D"ufs:/dev/md0"
         set kFreeBSD.mfsbsd.autodhcp=3D"YES"
}

Regards,
Navdeep




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42f7d662-3454-cae4-2141-f8b18dd543df>