Triple boot with GRUB

Triple boot with GRUB

Dual boot /
Triple boot with GRUB

GRUB home:
www.gnu.org/grub… (search for “GRUB” in www.ibm.com and read “Getting to know GRUB”.
Some GRUB for Linux… try also google/linux…, grub lin/win HOWTO, mini HOWTO… and an article about grub)

GRUB configurator…

Especially read using grub>… and solving boot problems with grub…


This is an introduction to my grub boot-loader setup.
Have one PC and 3 operating systems, each of them on separate hard disks. So I needed to setup a triple boot menu.

Note: I have installed an extra (PCI) IDE interface card for the 3.rd harddrive.

1.st drive has RedHat Linux 9 (pin setting for master drive. Cable is plugged into IDE connector on the mainboard)
2.nd drive runs Windows 98 (pin setting for slave drive. Connected to the same cable as master)
3.rd drive runs Vector Linux (pin setting for master drive. Cable is connected to an xtra IDE interface card)

Understanding GRUB:

Device names and corresponding drive and partition numbers in grub.

Harddrive names:
dev a = 0 in grub.
dev b = 1 –//—
dev c = 2 –//—
etc.

Partition numbers count from 0, 1, 2…

Examples:

HD device names Name/notation
and partitions: in grub:
============= =============
/dev/hda1 (hd0,0)
/dev/hda2 (hd0,1)
….
/dev/hdb1 (hd1,0)
/dev/hdb2 (hd1,1)
….
/dev/hdc1 (hd2,0)
etc.

GRUB setup

PC BIOS boot-order is set to fire from drive 1, it’s the RedHat disk.

RedHat CD #1 can be used as boot disk. Select ‘rescue’ boot option
or give the boot command:

boot: linux rescue (or: linux single)

0) I have booted into RedHat

Gathering first information about drives and partitions using fdisk.
Note, it’s L for listing.

# fdisk -l
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux RedHat Linux
/dev/hda2 14 14952 119997517+ 83 Linux
/dev/hda3 14953 15017 522112+ 82 Linux swap

/dev/hdb1 * 1 639 5132736 b Win95 FAT32 Windows
/dev/hdb2 640 1826 9534577+ f Win95 Ext’d (LBA)
/dev/hdb5 640 1826 9534546 b Win95 FAT32

/dev/hdg1 * 1 1 8001 83 Linux Vector Linux
/dev/hdg2 * 2 1149 9221310 83 Linux
/dev/hdg3 1150 1229 642600 82 Linux swap

Boot-log reveals also some useful data.

List boot log.
# dmesg | grep hd
# grep hd /var/log/messages
# grep hd var/log/dmesg

hda: IC35L120AVVA07-0, ATA DISK drive (RedHat Linux)
hdb: QUANTUM FIREBALLlct10 15, ATA DISK drive (Windoz 98)
hdc: _NEC CD-RW NR-9100A, ATAPI CD/DVD-ROM drive (cdrom)
hdg: IBM-DTTA-371010, ATA DISK drive (Vector Linux)
hda: 241254551 sectors (123522 MB) w/2863KiB Cache, CHS=15017/255/63, UDMA(33)
hdb: 29336123 sectors (15020 MB) w/1024KiB Cache, CHS=1826/255/63, UDMA(33)
hdg: 34746221 sectors (20110 MB) w/1024KiB Cache, CHS=19590/16/63, UDMA(33)

1) Install grub software

Download GRUB from www.gnu.org/software/grub and install it if not already done.
Read the INSTALL and README files.

Try to start grub form CLI if in doubt. (CLI = Command Line)
# grub
grub>
grub> quit

2) Initiate MBR (Master Boot Record) for grub

RedHat Linux resides on /dev/hda. Run grub-install as a root-user.
Note: grub-install ‘(hd0)’ is the same as grub-install /dev/hda1.

# grub-install ‘(hd0)’

MBR should now be on /dev/hda

(((
These grub-commands will do the same as grub-install ‘(hd0)’.
Ref. http://www.gnu.org/software/grub/manual/grub.html#Installation
Section “Installing GRUB natively”

Start grub (as root user)
# grub
grub> root (hd0,0) // Where (which drive/partition) to find /boot/grub/ ?
grub> setup (hd0) // Where (which drive) to write MBR (master boot record) ?
grub> quit
)))

Note: PC BIOS is set to boot from this RedHat disk.
Note: device.map file has now some important information over
mapping between device names and logical disk numering in grub. Study it !

# cat /boot/grub/device.map
(fd0) /dev/fd0
(hd0) /dev/hda
(hd1) /dev/hdb
(hd2) /dev/hdg

3) Defining boot-menu

Edit /boot/grub/grub.conf manually and create menu entries for each operating system.

3.1 Creating menu entry for RedHat

# fdisk -l
shows that Redhat lives on /dev/hda1

List bootable kernels. Select right kernel version.
# ls -l /boot

-rw-r–r– 1 root root 1133880 Aug 18 17:57 vmlinuz-2.4.20-13.9
-rw-r–r– 1 root root 149006 May 2 2003 initrd-2.4.20-13.9.img


This is our menu selection for RedHat.

title 1. RedHat Linux 9 (2.4.20-13.9)
root (hd0,0)
kernel /vmlinuz-2.4.20-13.9 ro root=LABEL=/ hdc=ide-scsi
initrd /initrd-2.4.20-13.9.img

! Note: If your system fails on the root=LABEL=/ statement, then replace it
with root=/dev/hdXX. In my case it would be root=/dev/hda1 because the root device is (hd0,0).
So this line is also correct: kernel /vmlinuz-2.4.20-13.9 ro root=/dev/hda1 hdc=ide-scsi

Note: You can remove old kernels with rpm -e. It also removes menu selection from the grub.conf.

# rpm -qa | grep kernel
# rpm -e kernel-2.4.xx.yy.z (thou do not remove the active, running kernel)

Note: hdc=ide-scsi is for cdrecord (cd burning application).
Cdrecord operates on SCSI devices only so we need to map IDE device “hdc” to SCSI bus.
It can be another drive depending on your system, e.g hdd=ide-scsi.
Note: This IDE to SCSI mapping is not needed in kernel v2.6… this article… has details.

3.2 Creating menu entry for Windows

# fdisk -l
shows that Windows is installed on /dev/hdb.

We need to swap MASTER and SLAVE because Windows neither can nor will boot directly from a SLAVE (hdb) drive.

title 2. Windows
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
makeactive
chainloader +1
boot

3.3 Creating menu entry for VectorLinux

# fdisk -l
VectorLinux drive appears as /dev/hdg.
This is a more tricky case.

Test-mounted several /dev/hdgX to find out right VectorLinux partition. Vector has ReiserFS filesystem.

# mkdir -p /mnt/test

# mount -t reiserfs /dev/hdg1 /mnt/test (tested /dev/hdg1, /dev/hdg2 etc…)
# ls -l /mnt/test/boot/

total 1648
-rw-r–r– 1 root root 512 May 18 11:27 boot.0300
-rw-r–r– 1 root root 179 May 18 11:27 boot_message.txt
-rw——- 1 root root 25088 May 18 11:28 map
-rw-r–r– 1 root root 553743 Feb 7 00:59 System.map
-rw-r–r– 1 root root 1234 Apr 2 09:01 VectorLinuxInfo.txt
-rw-r–r– 1 root root 1088144 Feb 7 01:00 vmlinuz

and got it right.

# umount /mnt/test
# rmdir /mnt/test

But how does grub understand this disk and partition number ?

Start grub again from command line
# grub
grub> root (hd2, [press TAB -key] (tested all hd numbers, hd0, hd1, hd2, hd3,…, hd6. )

Possible partitions are:
Partition num: 0, Filesystem type is reiserfs, partition type 0x83 got it !
Partition num: 4, Filesystem type unknown, partition type 0x82
Partition num: 5, Filesystem type unknown, partition type 0x83
grub> quit

Grub sees it as (hd2) and not as (hd6 for hdg), as I expected. Ok for me.
// 0 1 2 3 4 5 6
// a b c d e f g

Later I learned to read the device.map file, instead of guessing.
# cat /boot/grub/device.map

Well, That’s it.

4) Here is the final grub.conf file for a triple boot system

$ cat /boot/grub/grub.conf

# — beg —
#
# grub.conf generated by Anaconda installer, RedHat 9
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/.
# List all available boot-kernels with
#
ls -l /boot
#
# Example menu configuration:
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda2
# initrd /initrd-version.img
# boot=/dev/hda

# Note: hdc=ide-scsi entry is for cdrecord (RW CDROM).
# AFAIK: Kernel v2.6 does not need it?
This article… has details.

# Fire up RedHat after timeout (0=RedHat, 1=Windows, 2=VectorLinux, …)
default=0

timeout=10
# color=blue/white light-gray/blue
splashimage=(hd0,0)/grub/splash.xpm.gz

# —– REDHAT LINUX —–
title 1. RedHat Linux 9 (2.4.20-13.9)
# Master boot device
root (hd0,0)
kernel /vmlinuz-2.4.20-13.9 ro root=LABEL=/ hdc=ide-scsi
initrd /initrd-2.4.20-13.9.img

# —– WINDOWS —–
title 2. Windows
# Note:Windows cannot boot from SLAVE hd.
# So we need to swap hda(MASTER) and hdb(SLAVE)
map (hd0) (hd1)
map (hd1) (hd0)

rootnoverify (hd1,0)
makeactive
chainloader +1
boot

# —– VECTOR LINUX —–
title 3. Vector Linux (2.4.20)
root=(hd2,0)
kernel /boot/vmlinuz ro root=/dev/hdg1 hdc=ide-scsi

# — end —

5) Changing the menu background image (splashscreen)

Boot-menu.
More complete explanation is here GRUB Splash Image Howto.

Warning: GRUB needs a patch for splashimage functionality.
And the splashimage HOWTO is very Debian oriented, so I couldn’t make it to work on Mandrake 10 ! ¤!”##¤!

5.1 Create a new splash image with the GIMP editor

Menu background image must have size of 640×480 pixels.

$ gimp

– Create new image with [File], [New…]
– Set height: 480 and width: 640 pixels. (splashimage must have this size!)

– Design your image.
I normally select a nice color and employ the “Fill with color gradient” and “Fill with color or pattern” tools.
Select also regions and paint’em with different colors, add a photo, company logo, text etc.
Filters in Gimp are also very handy. Try e.g [Filter], [Light effects], [Supernova]. What an amazing effect. Isn’t it ?
Learn more about Gimp via references in www.futuredesktop.org.

5.2 Reduce number of colors to 14

From menu, select [Image], [Mode], [Indexed] (or press ALT + I) and set the number of color to 14.

5.3 Save your image as Xpm file

Select [File], [Save As..]

Set the file type : Xpm
Save it to /boot/grub/mysplash.xpm

5.4 Exit Gimp

Note: You can also use the “convert” tool to reshape an existing picture.
“convert” is part of the “imagemagick…” tool set.

Eg. this command converts a mypicture.jpg (size 1280×1024) to splash image.
# convert -size 1280×1024 mypicture.jpg -resize 640×480 -colors 14 -profile ‘*’ mysplash.xpm

—-

5.5 Open CLI and gzip the image

Goto command line (CLI) by starting xterm or konsole. Use gzip to squeeze the image.

# cd /boot/grub/
# gzip mysplash.xpm

You should now have a mysplash.xpm.gz file.
# ls -l

-rw-r–r– 1 root root 45830 Aug 23 23:59 mysplash.xpm.gz

Note: Gimp can open and save the compressed mysplash.xpm.gz directly.

5.6 Edit /boot/grub/grub.conf

# cd /boot/grub/
# kate grub.conf

A sample:
# ———— grub.conf —————–beg
default=0
timeout=10
# color=blue/white light-gray/blue
splashimage=(hd0,0)/grub/mysplash.xpm.gz

# —– REDHAT LINUX ——table
title Red Hat Linux (2.4.20-20.9)
root (hd0,0)
kernel /vmlinuz-2.4.20-20.9 ro root=LABEL=/ vga=794 hdc=ide-scsi
initrd /initrd-2.4.20-20.9.img

….
# ————- grub.conf —————-end

 

5.7 Changing menu colors

Set up specific colors to be used in the menu. Color setting is an alternative to the splashimage.

Syntax
color=textcolor/background [selected_line_textcolor/selected_line_background]

Valid text color names
black | blue | green | cyan | red | magenta | brown | light-gray |
dark-gray | light-blue | light-green | light-cyan | light-red | light-magenta | yellow | white

Valid background colors
black | blue | green | cyan | red | magenta | brown | light-gray

Sample color settings in grub.conf
color=black/light-gray
color=blue/white light-green/blue

Save the grub.conf and reboot
# reboot

5.8 Other

I have also added a vga=794 directive to the kernel line.
Text-console has now 1280×1024 resolution so it’s easier to read the long list of boot messages.

Table of VESA video modes:

640×480 800×600 1024×768 1280×1024 1600×1200 Ask user at boot
8 bits vga=769 vga=771 vga=773 vga=775 vga=796 vga=ask
16 bits vga=785 vga=788 vga=791 vga=794 vga=798 vga=ask
32 bits vga=786 vga=789 vga=792 vga=795 vga=799 vga=ask

Gentoo: kernel 2.6 and bootsplash…

© All Right Reserved 2019-2020 futuredesktop.org