Inside:
  Menu:
      Home
      FAQ
      Wishlist
      Photography
      UNIX Stuff
      PF Project
      Validate Me
      Contact Me
  Archived:
      11 May `04
      17 April `04
      5 April `04
      19 Mar `04
      3 Mar `04
      6 Feb `04
      14 Jan `04
      24 Dec `03
      15 Nov `03
      2 Nov `03
      20 October `03
      12 October `03
      4 October `03
      25 Sept `03
      14 Sept `03
      7 Sept `03
      31 August `03
      18 August `03
      6 August `03
      3 August `03
      31 July `03
      25 July `03
      20 July `03
Installing GRUB on FreeBSD
What is grub you might ask? Grand Unified Bootloader is what it stands for, if you use Redhat Linux you will most probably be familiar with grub as its the default operating system loader.

Grub offers greater configurability to the standard FreeBSD boot loader. My problem wasnt the way that the FreeBSD boot loader was working, it was the start up options on boot - I have a dual boot laptop with Windows XP and FreeBSD with two other partitions, one NTFS and one fat - I use the fat partition to share files between Windows and FreeBSD.

When I boot my machine I get this ugly boot loader screen that isnt configurable and for the NTFS partitions I get a ?, the fat partition is refered to as DOS and FreeBSD is recognised. I wanted the boot screen to display two options, Windows XP and FreeBSD, the only way I could do this was to install another boot loader, the best choice was grub.

FreeBSD offers grub as a port, so I went into the ports directory (/usr/ports/) then into the sysutils/grub/ directory. I then typed make && make install and the installation of grub was done in a couple of minutes. I was hoping that I wouldnt have to configure anything but the final install message confirmed this was not to be the case:

###########################################################
This port does not install GRUB on the master boot record
of your hard drive.
To do this, or to use it with a floppy disk, you will need
to read the info page using 'info grub'.
###########################################################

I scratched my head for a few moments and pondered on what I was going to do, I have never actually done a manual install of a boot loader into the master boot record - I could make or break my system!

When grub is installed, boot images are installed to a default directory, /usr/share/grub/i386-pc and of course this is not the case on freebsd (or probably any other bsd unix, everything seems to be Linuxised). A quick fiddle around and I came up with the following directory, /usr/local/share/grub/i386-freebsd/.

I now knew where the boot images resided, my next step was to make a grub directory in the boot directory. I typed (as root user of course) mkdir /boot/grub/, I then changed directories to /usr/local/share/grub/i386-freebsd/ and issued the following commands:

cp stage1 /boot/grub/
cp stage2 /boot/grub/
cp *stage1_5 /boot/grub/

These commands copied the boot images into the /boot/grub/ directory. Next thing I had to do was create a grub boot floppy, this was done by nserting a floppy disk into the floppy drive and issueing the following commands (you must be in the /usr/local/share/grub/i386-freebsd/ directory):

# dd if=stage1 of=/dev/fd0 bs=512 count=1
(this was the output)
1+0 records in
1+0 records out
512 bytes transferred in 1.230979 secs (416 bytes/sec)
# dd if=stage2 of=/dev/fd0 bs=512 seek=1
(this was the output)
192+1 records in
192+0 records out
98304 bytes transferred in 4.694965 secs (20938 bytes/sec)

Next thing to do is reboot with the floppy that you just made as a start disk and pray that you have done this right. Once you have rebooted you will get a command prompt that looks like this: grub> issue the command find /boot/grub/stage1 to find the location of the stage1 boot image. I got hd0,3,a

Next command to issue is root (hd0,3,a) which creates that as your root location. Finally issue setup (hd0) command to install grub to the master boot record. now you dont have to use the floppy to load grub.

Then issue kernel /boot/loader then boot and grub will boot you into FreeBSD, you then need to create a menu.lst file in your /boot/grub/ directory - this is what allows you to choose which operating system you want to boot into. my menu.lst file looks like this:

timeout=10
title WindowsXP
root (hd0,0)
makeactive
chainloader +1
boot
title FreeBSD
root (hd0,3,a)
kernel /boot/loader

This gives me a default timeout of 10 seconds and makes Windows XP the default operating system (I dont know why did that as I hardly ever use Windows). Now when you reboot your system you will get a grub menu and you can use your arrow keys to navigate which operating system you want to boot!

For more info on this use the info grub command to view the detailed instructions, and remember if you dont know what your doing dont attempt this because if you make an error you wont be able to boot your computer.