How do I add a menu entry to grub2 for FreeBSD

Asked by tomdean

I have Ubuntu 11.10 and FreeBSD on the same GPT disk, sdb. I have Windows 7 on sda. Update-grub pickup the windows system.

Update-grub does not pick up the FreeBSD system.

How do I add an entry via /etc/grub.d/12_FreeBSD? Or, use something to create the entry?

$ sudo parted /dev/sdb print
Model: ATA WDC WD5000AAKX-6 (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
 1 17.4kB 100GB 100GB ext4
 2 100GB 132GB 32.0GB linux-swap(v1)
 3 132GB 132GB 65.5kB
 4 132GB 495GB 363GB freebsd-ufs
 5 495GB 499GB 4295MB

$ sudo mount -t ufs -o ufstype=ufs2 -r /dev/sdb4 /mnt
tomdean@P9X79:~$ ls /mnt
bin COPYRIGHT etc libexec mnt rescue sbin tmp var
boot dev lib media proc root sys usr
tomdean@P9X79:~$ ls /mnt/boot
beastie.4th check-password.4th gptzfsboot menu-commands.4th userboot.so
boot color.4th kernel menu.rc version.4th
boot0 defaults loader modules zfs
boot0sio delay.4th loader.4th pmbr zfsboot
boot1 device.hints loader.help pxeboot zfsloader
boot2 firmware loader.rc screen.4th
brand.4th frames.4th mbr shortcuts.4th
cdboot gptboot menu.4th support.4th

tomdean

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Solved by:
tomdean
Solved:
Last query:
Last reply:
Revision history for this message
tomdean (tomdean) said :
#1

This works from grub menu - press c and enter the internal parts of the entry then use
the boot command.
menuentry "FreeBSD, with kFreeBSD kernel" --class freebsd --class bsd --class os {
        insmod part_gpt
        insmod ufs2
        set root='(hd1,gpt4)'
        echo Loading kernel of FreeBSD kernel ...
        kfreebsd /boot/kernel/kernel
        kfreebsd_loadenv /boot/device.hints
        set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ad1p4
        set kFreeBSD.vfs.root.mountfrom.options=rw
}

Revision history for this message
Redemblem (redemblem101) said :
#2

Which version of FreeBSD are you using? I am trying to do roughly the same thing, though the version of GRUB2 that I am using is the EFI x86_64 version from Arch Linux repos. When I try to load the FreeBSD kernel using the same methods you have put my system simply reboots.

I assume your /dev/ad1p4 is your FreeBSD "/" partition and the /dev/ad1p3 is your "FreeBSD-boot" partition for the GPT scheme based on what you put above.

Revision history for this message
tomdean (tomdean) said :
#3

On 03/22/12 16:50, Redemblem wrote:
> Your question #181019 on grub2 in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/grub2/+question/181019
>
> Redemblem posted a new comment:
> Which version of FreeBSD are you using? I am trying to do roughly the
> same thing, though the version of GRUB2 that I am using is the EFI
> x86_64 version from Arch Linux repos. When I try to load the FreeBSD
> kernel using the same methods you have put my system simply reboots.
>
> I assume your /dev/ad1p4 is your FreeBSD "/" partition and the
> /dev/ad1p3 is your "FreeBSD-boot" partition for the GPT scheme based on
> what you put above.
>

menmuentry "FreeBSD 9.0 (RC2)" {
  insmod part_gpt
  insmod ufs2
  set root='(hd1,gpt4)'
  kfreebsd /boot/loader
  kfreebsd_loadenv /boot/device.hints
  set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada1p4
  set kFreeBSD.vfs.root.mountfrom.options=rw
}

Tom Dean