A Bootable Grub CD



Introduction

My BIOS had the restriction that it could only boot from the first hard drive, which in my case had the FreeBSD bootloader on it. I had a second disk with Vista loaded on it, which I use from time to time for university work.

So I needed a method of booting the second hard disk. I decided to make a bootable CD with grub.

These are the instructions for building a Grub CD for booting Vista, FreeBSD and XP using FreeBSD to burn the disk.


Instructions

Installation of Grub is straight forward, just install it from ports. It's under sysutils/grub in your ports tree.

Then make a directory:


$ mkdir -p ~/grub/iso/boot/grub

Change directory:


$ cd ~/grub

Copy stage2_eltorito to it:


$ cp /usr/local/share/grub/i386-freebsd/stage2_eltorito ./iso/boot/grub/

Create menu.lst :


$ vim iso/boot/grub/menu.lst

and put something like the following in it (obviously, with the disk id's of your own setup):


# By default, boot the first entry.
default 0

# Boot automatically after 10 secs.
timeout 10

# Fallback to the second entry.
fallback 1

# For booting FreeBSD 
# For root partition: ad0s2
title  FreeBSD
rootnoverify   (hd0,1,a)
chainloader +1

# Vista
title  Vista
root        (hd1,0)
makeactive
chainloader +1

# XP
title  XP
root        (hd0,0)
makeactive
chainloader +1

# For installing GRUB on to the hard disk (untested)
title Install GRUB on to the hard disk
root    (hd0,0)
setup   (hd0)

# Change the colours.
title Change the colours
color light-gray/blue  red/light-gray

     

Next you have to install sysutils/cdrtools if it isn't installed already. It contains a program called mkisofs which appropriately enough creates iso images.

You can then create your iso:


$ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
-boot-load-size 4 -boot-info-table -o grub.iso iso

Then burn your CD:


# burncd -f /dev/acd0 data grub.iso fixate

You should now have a bootable CD.

Test it out buy leaving it in your CD tray & setting your BIOS to reboot from the CD drive.

Bugs

Only tested on FreeBSD 6.3-RELEASE.

I haven't tested out the write to HD option as I don't want to lose my original FreeBSD bootloader