Adding PC-BSD to Grub Version 2

From PC-BSD Wiki
Revision as of 10:56, 1 October 2010 by Drulavigne (Talk | contribs)

Jump to: navigation, search
Return to Table of Contents
Previous: Adding PC-BSD to Grub Version 1
Next: Dual Boot with Windows Using EasyBCD

If your Linux distro is using grub version 2, the entry would now look like this:

title  PCBSD 8.1
root   (hd0,1,a)
kernel /boot/loader

Here are some examples of more complex grub version 2 entries:

To set some sysctl values when loading the kernel:

menuentry "PCBSD (FreeBSD) 8.1" {
 insmod ufs2
 set root=(hd0,3)
 kfreebsd /boot/kernel/kernel
 set KFreeBSD.vfs.root.mountfrom=ufs:dev/label/rootfs0
 set KFreeBSD.vfs.root.mountfrom.options=rw

To use the specified drive UUID:

First, at a command prompt in the PC-BSD system, determine the UUID with this command:

# /usr/local/sbin/grub-probe -d /dev/ad4s1 -t fs_uuid

Then, use that UUID in the grub menu entry:

menuentry "FreeBSD ad4, direct" {
 insmod ufs2
 set root=(hd0,1,a)
 search --no-floppy --fs-uuid --set 4b22f9090565ab77
 kfreebsd /boot/kernel/kernel
 kfreebsd_loadenv /boot/device.hints
 set KFreeBSD.vfs.root.mountfrom=ufs:/dev/ad4s1a
 set KFreeBSD.vfs.root.mountfrom.options=rw

To use ZFS on GPT Partition:

zfs set mountpoint=legacy on all datasets on ${ZPOOL} and manage mountpoints in ${ZFSDATASET-INSTALLATION}/etc/fstab

menuentry "FreeBSD install in ${ZFSDATASET-INSTALLATION} (i.e. 8.1-RELEASE-amd64) on ${ZPOOL} (i.e. zroot)" {
          insmod zfs
          # search for ${ZPOOL}
          search -s -l zroot
# Load kernel of FreeBSD, kfreebsd /${ZFSROOTDATASET}/${ZFSDATASET-INSTALLATION}@/boot/kernel/kernel (-aCcDdghmnPpqrsv)
          kfreebsd /8.1-RELEASE-amd64@/boot/kernel/kernel
          kfreebsd_module_elf /8.1-RELEASE-amd64@/boot/kernel/opensolaris.ko
          kfreebsd_module_elf /8.1-RELEASE-amd64@/boot/kernel/zfs.ko
# Loading kernel modules (${VAR}_load="YES") here, /boot/loader.conf isn't processed 
#         kfreebsd_module_elf /${ZFSDATASET-INSTALLATION}@/boot/kernel/${VAR}.ko
          kfreebsd_module /8.1-RELEASE-amd64@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
          set kFreeBSD.vfs.root.mountfrom=zfs:zroot/8.1-RELEASE-amd64
# Loader Tunables (${TUNABLE}="variable" -> set kFreeBSD.${TUNABLE}=variable)


After a Grub2 configuration change you need to run update-grub as the superuser or sudo update-grub.

For more information please refer to the Grub 2 manual

Personal tools