3.5 Configuring a Tri-boot with GRUB
For
GRUB experts, kindly proceed and make the modifications as required in
the menu.lst file in CentOS. For GRUB newbies, there is a wealth of
information available at: http://www.gnu.org/software/grub/grub.html most of which is self-explanatory and easy to understand. If there is something that you do not understand, shoot me a mail.
GNU GRUB stands for the GRand Unified Bootloader, which is a very powerful boot loader
program for PCs. Detailed manual for GRUB (version 0.97) can be accessed by:
- Online: http://www.gnu.org/software/grub/manual/ wherein different formats are available for easy perusal.
- CentOS: Open a terminal, type in: info grub which opens up the Detailed manual for GRUB (version 0.97) on your screen.
In Section 4.1
of the manual for GRUB (version 0.97), lies the secret of how to
boot OSes successfully. As mentioned therein, GRUB has two
distinct boot methods - either booting the OS directly or when GRUB is
unable to provide native support to the OS in question, it fires
the boot loader of the OS via a chain-loading mechanism; thereby
enabling the OS to boot successfully. For CentOS 5.2, GRUB loads the OS
directly, whereas for WinXP it needs to fire up the boot loader for
Windows via chain-loading mechanism.
One point which readers ought to keep in mind is that chain-loading
mechanism normally operates on the assumption that the boot loader is
embedded in the boot sector of the
active partition on which the OS is installed.
= = STEPS TO FOLLOW = =
Step1: Login to CentOS 5.2, open a terminal, gain superuser rights (referred to as root) by using the su command and providing the password that you had provided whilst installation.
[ghosh@pluton ~]$ su
Step2: Once you have root access, type the following commands at the terminal:
[root@pluton ghosh]# cd /
[root@pluton /]# cd /boot/grub
[root@pluton grub]# ls -al
[root@pluton grub]# cp grub.conf grub.conf.bak
This
creates a backup file for the grub.conf file which is the configuration
file for GNU GRUB boot loader. In the listing of all files on the
screen, you can also see menu.lst -> ./grub.conf which means
menu.lst is a soft or symbolic link to the GRUB configuration file
grub.conf.
Step3: [root@pluton grub]# vi grub.conf
Step4: My grub.conf is displayed on the screen:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, e.g.
# root (hd0,2)
# kernel /boot/vmlinuz-version ro root=/dev/sda3
# initrd /boot/initrd-version.img
# boot=/dev/hda
default=1
timeout=60
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-92.el5)
root (hd0,2)
kernel /boot/bzImage.2.6.18-92.el5 ro root=LABEL=/ rhgb quiet crashkernel=512M@16M
initrd /boot/initrd-.2.6.18-92.el5.img
title Windows
rootnoverify (hd0,0)
chainloader +1
Step5: Edit the file contents and add the lines which are marked in blue.
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, e.g.
# root (hd0,2)
# kernel /boot/vmlinuz-version ro root=/dev/sda3
# initrd /boot/initrd-version.img
# boot=/dev/hda
default=1
timeout=60
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu
title Windows
rootnoverify (hd0,0)
chainloader +1
title OpenSolaris
rootnoverify (hd0,1)
savedefault
makeactive
chainloader +1
title CentOS (2.6.18-92.el5)
root (hd0,2)
kernel /boot/bzImage.2.6.18-92.el5 ro root=LABEL=/ rhgb quiet crashkernel=512M@16M
initrd /boot/initrd-.2.6.18-92.el5.img
Step6:
I have rearranged the code in accordance to the geometrical layout of
the partitions in the hard disk. WinXP first, followed by OpenSolaris
slice and finally, the CentOS partition. Save and exit vi editor.
Step7: [root@pluton grub]# /sbin/reboot
This restarts the PC. When the system finally comes up, press any key to see the GNU GRUB version 0.97 screen, which displays:
Windows
OpenSolaris
CentOS (2.6.18-92.e15)
- Selecting Windows and pressing <ENTER> boots your system into WinXP.
- Selecting OpenSolaris and pressing <ENTER> loads the OpenSolaris GRUB boot loader via chain-loading mechanism. It has our earlier OpenSolaris entries plus the WinXP boot entry. Check whether all working correctly or not.
- Selecting CentOS (2.6.18-92.e15) and pressing <ENTER> boots CentOS 5.2.
Thus, as promised, we have:
a)
Successfully partitioned a new single hard disk drive into primary and
extended partitions with WinXP FAT32, OpenSolaris ZFS and Linux ext3
filesystems on them.
b) Successfully installed Microsoft WinXP on the first primary partition of the hard disk.
c) Successfully installed OpenSolaris 2008.11 on the second primary partition of the hard disk.
d) Successfully installed CentOS 5.2 on the third primary partition of the hard disk (with Linux swap on a logical disk drive of the extended partition).
e)
Successfully edited the GRUB configuration file /boot/grub/grub.conf
and configured a tri-boot system with WinXP, OpenSolaris and CentOS OSes.