DæmonNews: News and views for the BSD community

February 2001 Get BSD New to BSD? Search BSD Submit News FAQ Contact Us Join Us
Search


Get BSD Stuff

Booting FreeBSD with grub

Georg Wagner

1  What is grub?

Grub

2  Preparing the installation of grub

2.1  Getting grub

I was never able to compile grub from source on a FreeBSD system before release 4.0. Therefore I used to rip grub out of a Debian Linux distribution. Nowadays you can download a precompiled copy from ftp://alpha.gnu.org/gnu/grub/.

The last version I used is:  grub-0.5.96.1-i386-pc.tar.gz 

There is even a working port in the port collection now.

2.2  Installing the files

Unzip and detar the tarball by:

# tar zxvf ./grub-0.5.96.1-i386-pc.tar.gz

Now change to the directory /boot, create a subdirectory named grub and copy the files stage1, stage2, and menu.lst into the new directory.

$ cd /boot

# su toor

# mkdir grub

# cd grub

# cp /path_to_grub/grub-0.5.96.1-i386-pc/stage1 .

# cp path_to_grub/grub-0.5.96.1-i386-pc/stage2 .

# cp /path_to_grub/grub-0.5.96.1-i386-pc/menu.lst .

2.3  Editing menu.lst

Edit the file /boot/grub/menu.It should contain the following contents:

# For booting FreeBSD 

title FreeBSD 

root (hd1,a) 

kernel /boot/loader

# For booting Windows NT or Windows95 

title Windows NT / Windows 95 boot menu 

root (hd0,0) 

makeactive 

chainloader +1 

boot

# For loading DOS if Windows NT is installed 

# chainload /bootsect.dos

The same as the above, just for Windows. 

# For installing GRUB into the hard disk 

title Install GRUB into the hard disk 

root (hd0,0) 

setup (hd0)

Remarks: The install string should reflect your personal system. On my machine, FreeBSD resides on the second SCSI disk sd1 and I prefer to boot from floppy disk.

Older versions of grub could not load the new ELF-kernel of FreeBSD. Therefore it was necessary to boot the kernel indirectly via /boot/loader. Even now this is the preferred method, because of the many useful features of /boot/loader.

2.4  Generating the bootable install disk

Since I could not compile grub under FreeBSD the final installation has to be done via the boot disk (otherwise you could use the grub shell directly).

Insert a floppy disk into your drive, su to root, then issue the commands:

# cd /boot/grub

# dd if=stage1 of=/dev/fd0 bs=512 count=1

# dd if=stage2 of /dev/fd0 bs=512 seek=1

If everything worked you should have now a bootable install disk for booting from floppy.

3  Installing grub

Reboot your machine and wait until you are in the grub shell. Then enter (all on one line):

install=(hd1,a)/boot/grub/stage1 d(fd0)

(hd1,a)/boot/grub/stage2 0x8000 p 

(hd1,a)/boot/grub/menu.lst

The first part tells grub where to find its stage1. The second part tells grub to install its bootsector on a floppy (fd0) (insert a new one before hitting return, if you want to keep your install disk). The third part tells where to find stage2 and the last part tells where the menu file resides. I omitted the part with 0x8000 p, if you want to know more read the manual. One interesting point: the d in front of (fd0) is described as optional in the manual, but all installations I tried failed when this option was omitted.

4  References

  1. Grub's Home: http://www.gnu.org/software/grub/grub.en.html
  2. Download grub: ftp://alpha.gnu.org/gnu/grub/
  3. The grub manual: http://www.mcc.ac.uk/grub/grub_toc.html
  4. Erik Boleyn's original grub: http://www.uruk.org/~erich/grub/




Author maintains all copyrights on this article.
Images and layout Copyright © 1998-2004 Dæmon News. All Rights Reserved.