Saturday, September 4, 2010

Dual booting *BSD with the new GRUB

With the new version of GRUB (1.98) there have been a lot of changes in the way things work. In the earlier versions of GRUB, the following entry was added to /boot/grub/menu.lst to boot into OpenBSD

title OpenBSD 3.0
root (hd0,0)
chainloader +1

The newer versions of Grub do not have the menu.lst anymore but are replaced by /boot/grub/grub.cfg.

Unlike menu.lst this file is never hand edited but gets auto-generated by the /usr/sbin/grub-mkconfig
using templates from /etc/grub.d and settings from /etc/default/grub.

To add entries for other operating systems, the entries are made in /etc/grub.d/40_custom file and grub-mkconfig is run, which generates /boot/grub/grub.cfg

One change that has to be noticed is the partition entry numbering start from 1. First partition in hd0 is (hd0, 1) which was (hd0, 0) in earlier versions.

To dual boot the *BSD systems, the following entries have to be added to /etc/grub.d/40_custom and run grub-mkconfig -o /boot/grub/grub.cfg, by default grub-mkconfig outputs to stdout.

menuentry "NetBSD 5.0.2" {
set root=(hd0,1)
parttool (hd0,1) boot+
chainloader +1

menuentry "FreeBSD 8.0" {
set root=(hd0,2)
parttool (hd0,2) boot+
chainloader +1

menuentry "OpenBSD 4.7" {
set root=(hd0,3)
parttool (hd0,3) boot+
chainloader +1