FreeOS.com logo

FreeOS Most Popular
* Most Read stories
* Commented Stories
* Active Categories
* Non Linux Section
* User Submitters
* Top Polls
* Top Authors
* Top Reviews
* Top Rated
* Top Search Terms

Top Articles
* Writing a Linux device driver
* The Linux filesystem explained
* Samba NT Domain Controller
* Setting up Squid as your caching HTTP/FTP proxy
* Web server tutorial - Part 1

FreeOS Highlights
* Howtos (72)
* Reviews (20)
* Opinions (18)
* Interviews (8)
* News (3)

My FreeOS

Nick:
Pass:
Register

Forgot your password?

Contact Us
Contact Us

       

Project: Linux triangle Howtos triangle

GRUB: Multi-boot without LILO!

By Mayank Sarup <mayank@freeos.com>
Posted: ( 2001-02-07 14:05:48 EST by mayank )

LILO is one of the most widely used bootloaders on multi-boot systems. Another open source alternative coming up is GRUB (GRand Unified Bootloader). We came across GRUB during a Mandrake installation, which brought up this article as we were curious to see what it was and how it could replace LILO.

GRUB, unlike LILO, is able to read filesystems and recognize kernel images too. While LILO requires the physical location of the kernel on your drive, GRUB does not. Even the latest filesystem ReiserFS is supported. This means that you don't have to re-install GRUB every time you make a change to the config file or install a new kernel. If your BIOS supports LBA then there is also no problem reading beyond 1024 cylinders. There's some good support for network booting of diskless clients. On the other hand, GRUB installation can be a bit of a problem. Maybe we're all too used to LILO or maybe GRUB still has some way to go? Little of both we think.

GRUB can be obtained from ftp://alpha.gnu.org:/gnu/grub/. The official page where you can look for documentation and FAQ's is http://www.gnu.org/software/grub/. According to the site, the software hasn't been released publicly and the various releases are merely test releases. We haven't faced problems setting up and booting GRUB but there are several known bugs and missing features that might trip you up. The latest release as of writing this article is 0.5.96.1 and this is what we'll be using here.

Installation

Simply un-tar the file somewhere.

bash-2.04$ tar zxvf grub-0.5.96.1.tar.gz

Enter the directory "grub-0.5.96.1" and run the following sequence of commands there

mayank@agni:/tmp/grub-0.5.96.1 > ./configure
mayank@agni:/tmp/grub-0.5.96.1 > make
mayank@agni:/tmp/grub-0.5.96.1 > su -c "make install"

Configuration

GRUB provides a menu-based interface that you can use. By default GRUB will install into /boot/grub and the configuration file will also reside there. The default configuration file is menu.lst. This is the GRUB equivalent of lilo.conf. This is the file where you define the various boot options, boot images etc.

A sample menu.lst file is given below

timeout 5
color black/yellow yellow/black
default 0
password freeos

title My Linux
kernel (hd0,1)/vmlinuz root=/dev/hda3 idebus=66

title Another Distro!
kernel (hd0,6)/boot/vmlinuz root=/dev/hda7 idebus=66

title Windows
root (hd0,0)
makeactive
chainloader +1

Let's look at the configuration options given here

timeout - The delay in seconds before the default entry is booted.

color - The color combination for the menu. The first entry is the foreground and background color of an entry in the menu and the second is the color combination to be used when a entry is highlighted.

default - The default entry that will be booted after the timeout value is reached. Here we've given '0' as the default. This means that the first boot entry will be used. GRUB counts up from '0' and not from '1'. So the first entry would be '0' and the second '1'.

password - This is the password to be used if someone wants to access GRUB's advanced features at boot. GRUB puts some very powerful features at your disposal because of its ability to read filesystems. For example, at the grub boot prompt, someone can just type 'cat /etc/shadow' and read your shadow passwords -- without even booting into your system! Using a password restricts such actions to authorized users only. This password will also be used to prevent booting of other users.

Now come the boot entries. Each boot entry starts with the keyword 'title', followed by any string that describes that entry. Next are the 'kernel' entries. We've not worked with the BSD's, but the process of booting the BSD's is very well documented in the texinfo manual. For the moment, we’re sticking with Linux.

kernel (hd0,1)/vmlinuz root=/dev/hda3 hdc=ide-scsi

The line above is pretty self-explanatory but for GRUB's naming convention of your devices. Floppy drives become (fdx) and hard drives become (hdx) where 'x' is the number of the device. One thing to remember is that GRUB counts up from '0' and not '1'. hd0 represents the first hard drive and hd1 the second. All device names are enclosed within brackets. Further, hard drive partitions are specified with a comma separating the two. e.g - (hd0,1) means second partition on the first device. Similarly, (hd1,5) refers to the first logical partition on the second hard drive.

GRUB can read most filesystems, and in the above line we set it up so that GRUB looks for the kernel in (hd0,1), which is the second primary partition on the first hard drive and the file '/vmlinuz'. You will also have to give 'root=/dev/hda3' or wherever your root filesystem lies, otherwise the kernel will not be able to mount the root filesystem. After this, you can put in any parameters that you want to pass to the kernel. These parameters are specified, as they would be when using LILO.

The other entry you will see here for booting Windows. This entry is a little different. The root entry here points to the root partition (c:) of your DOS/Windows installation. The next entry sets the active flag on the partition. The final entry tells GRUB to grab the first sector of the partition -- booting the OS there.

This was the configuration of the most common dual-boot setup for GRUB. Now you have to install GRUB as your boot loader. Keep a LILO floppy or a rescue disk in hand before you do so.

grub-install /dev/hda

Login as root and run the command "grub". You will then be looking at the following

GRUB version 0.5.96.1 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]

grub>

This is the grub prompt that we will use to install GRUB on the hard drive. There's one long and complicated command-line that we're going to use.

grub> install (hd0,1)/boot/grub/stage1 d (hd0) (hd0,1)/boot/grub/stage2 p (hd0,1)/boot/grub/menu.lst

GRUB is divided into 2 major stages: stage1 and stage2. Stage1 is the tiny code that is embedded into the MBR. Stage2 is the main component here and handles everything else after Stage1 transfers control to it at boot-up.

The relevant parts of the command-line here are the first parameter given after ‘install’. This should point to the location of stage1 on your hard drive. As you can see, we're using the full drive notation as well as pointing to a specific directory on the partition. This is possible because GRUB can read filesystems. The 'd' parameter means that Stage1 will look for the disk where Stage2 is installed. (hd0) is the location where GRUB will be installed to. Since we want to use it as our primary boot loader, this means that it will install to the MBR. You can also point it to the root partition of your filesystem. The next parameter is the location of Stage2. This is also specified in the same manner as for Stage1. Then comes 'p' followed by the location of the configuration file menu.lst.

One problem that could arise with the above notation is if /boot is a separate partition. Let’s say (hd0,1) (hda2), is being mounted as /boot on your system. (hd0,2) (hda3) is your root partition. The above installation would have to be modified to the one below. You cannot say (hd0,2)/boot/grub/stage1 because GRUB does not know that (hd0,1) is mounted as /boot on your system. In this case, you will have to point first to the partition that is mounted as /boot and then to the grub directory under it.

grub> install (hd0,1)/grub/stage1 d (hd0) (hd0,1)/boot/grub/stage2 p (hd0,1)/grub/menu.lst

Reboot and you will have a decent GRUB menu in your hands. In case of any configuration problems you can check the web site or the locally installed documentation. The manual pages are in texinfo format so use ‘info grub’ to get to the real detailed documentation (‘man grub’ will give you very basic information).

This was a installation guide to GRUB. We’re leaving it in place for a while as we evaluate the pros and cons of using this over LILO. It’s not difficult to configure or install but if LILO is working fine then you probably should leave that as is. On the other hand, GRUB has some neat and powerful features that should be explored further.

GRUB Home

Other articles by Mayank Sarup

Current Rating: [ 7.71 / 10 ] Number of Times Rated: [ 145 ]

More Howtos
* Kernel Compilation & Avoiding ‘Unresolved Symbol’
* Configuring CVS and CVSUP on Linux
* Knoppix installation tips
* Maximum Mount
* A WebServer Guide -- Help Using Apache

Contents
Articles
  Howtos
  Interviews
  News
  Opinions
  Reviews
Comparison
Links
  Articles
  Howtos
  Interviews
  Opinions
  Reviews
  Websites
News

Linux
About Linux

Print It!
Printer Friendly Version