Besides Linux and Hurd, Grub2 has native support for FreeBSD, NetBSD and OpenBSD, and can boot any OS which complies to the multiboot specification.

FreeBSD

Direct Kernel Boot

GRUB can boot a FreeBSD kernel by using the kfreebsd command. The procedure would look like this:

1. Set the partition where resides the FreeBSD kernel:

set root=(/dev/ad4,msdos1)

2. Load the kernel

kfreebsd /boot/kernel/kernel

3. Load the kernel boot information

kfreebsd_loadenv /boot/device.hints

4. Set the root device-path

set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ad4s1a

5. Set any file-system options to pass

vfs.root.mountfrom.options=rw

6. Finally, run the command

boot

The list of all available options for the kfreebsd command can be seen by running kfreebsd --help from the GRUB prompt.

Example, using /etc/grub.d/40_custom

A FreeBSD entry in /etc/grub.d/40_custom should look like this:

menuentry "FreeBSD 8.0 direct" {
        insmod ufs2
        set root='(/dev/ad4,msdos1)'
        search --no-floppy --fs-uuid --set 4c0029f407b3cd1d
        kfreebsd /boot/kernel/kernel
        kfreebsd_loadenv /boot/device.hints
        kfreebsd_module /boot/splash.bmp type=splash_image_data
        set kFreeBSD.vfs.root.mountfrom=ufs:ad4s1a
}

You can get the fs_uuid from the Grub2 command line by typing:

ls (hd0,1)

It is possible to define the FreeBSD bootloader options ( /boot/loader.conf ) in the form of set commands.

For instance, to force the kernel to wait for USB devices to appear:

set kFreeBSD.kern.cam.boot_delay="10000"

NetBSD

Direct Kernel Boot

GRUB can boot a NetBSD kernel by using the knetbsd command. Procedure is as follows:

1. Set the partition where resides the NetBSD kernel. If NetBSD is installed on the first partition of your first hard disk, you would need:

set root=(hd0,msdos1)

2. Load the kernel and specify the root device-path:

knetbsd /netbsd --root=wd0a

3. Finally, run the command

boot

The list of all available options for the knetbsd command can be seen by running knetbsd --help from the GRUB prompt.

Example, using /etc/grub.d/40_custom

menuentry "NetBSD on sda1" {
insmod ufs2
set root=(hd0,msdos1)
knetbsd /netbsd --root=wd0a
}

Generic Multi-Boot

Booting a multi-boot compliant kernel, requires loading the kernel with the 'multiboot' command, and then executing it with the 'boot' command. An example of very simple but fully compliant kernel, is the Grub Invaders game which you can start this way:

1. Load Grub Invaders with the command multiboot

multiboot /boot/invaders

2. Run the command

boot

Chain Loading

If you want to use FreeBSD or NetBSD's own boot program, it is perfectly fine to chain load the OS by specifying the partition. A custom entry would look like this:

menuentry "FreeBSD"{
    set root=(hd0,msdos1)
    chainloader +1
}


CategoryBootAndPartition

Grub2 Other Os (last edited 2012-08-23 15:42:52 by emmanuel-kasper)