SDB:Booting a Second Linux System with the Boot Loader GRUB

From openSUSE


Versions: 8.1 - 10.3 - 


Contents

Concern

You have two Linux systems installed on your machine and want to boot both with the boot loader GRUB.


Supposition

Suppose the hard disk is partitioned as follows:

/dev/hda5      Swap
/dev/hda6      Linux 1
/dev/hda7      Linux 2

The first logical partition (/dev/hda5) is the swap partition, /dev/hda6 contains the first Linux system. This system is booted with the boot loader GRUB. Another Linux version is to be installed in the partition /dev/hda7. This version, too, is to be booted with GRUB.


Procedure

When installing the second Linux system, do not install the boot loader in the MBR but in the root partition (/dev/hda7). Subsequently, add the following section for the second system to the boot loader configuration file of the first installation (/boot/grub/menu.lst):

title Linux Two
   root (hd0,6)
   chainloader +1

The entry root (hd0,6) must be adapted to your situation. In this example, (hd0,6) refers to the third logical partition on the first hard disk. Further information on the designations used in the entries in the GRUB configuration file is available in the following article: SDB:The Boot Manager Grub

Save the file. The next time you power up the machine, the boot manager will show the additional entry. Select this entry to start the chain loader mechanism of the boot loader of the second Linux system. In this way, two boot loaders are used consecutively. The advantage of this procedure is that the boot loader of the second system can be configured quite easily.


Other ways: 1) No chain loader

Alternatively, the kernel, initrd, and kernel parameters can be entered directly in the boot loader of the first system. For example, the following entry boots a SUSE LINUX 9.1 installation:

title Linux Two
    kernel (hd0,6)/boot/vmlinuz root=/dev/hda7 vga=794 resume=/dev/hda5 splash=verbose showopts
    initrd (hd0,6)/boot/initrd

The disadvantage of this procedure is that the boot loader cannot be reconfigured from the second system without mounting the partition containing the first system. The advantage is that only one boot loader is needed for booting both systems.


Other ways: 2) Installing a second openSUSE 10.3 on a USB memory stick, and booting

This works only with modern computers (as of 2008) that are able to boot from USB devices, and with openSUSE 10.3.

There is also a Windows Vista, and another openSUSE 10.3 installation on the computer. They have their boot loader installed on the master boot record of the internal hard drive. We don't discuss that booting here. Thus the computer can boot by itself, without the USB memory stick.

Our goal is to install an openSUSE 10.3 on the USB memory stick, in a manner that all three OSs will be bootable when the stick is plugged in.

Naturaly, the boot order in BIOS must be fixed, preferably as follows:

 1) DVD drive
 2) USB stick
 3) USB hard drive
 4) Internal SATA hard drive

After fixing the sequence in BIOS, partition and install openSUSE 10.3 on the USB memory stick. The partitions may look like this (as fdisk -l reports). Don't worry about the bootability flags yet:

=======================================================================
Partition   Bootability     Mountpoint or type    GRUB name (see later)
-----------------------------------------------------------------------
The hard drive:
/dev/sda1   *               /windows              (hd1,0)
/dev/sda2                   Unimportant           (hd1,1)
/dev/sda3                   Extended for Linux
/dev/sda5                   /boot                 (hd1,4)
/dev/sda6                   /                     (hd1,5)
/dev/sda7                   Unimportant           (hd1,6)
/dev/sda8                   /home                 (hd1,7)
/dev/sda9                   swap                  (hd1,8)
The USB  memory stick:
/dev/sdb1   *               Extended
/dev/sdb5                   swap                  (hd0,4)
/dev/sdb6                   /                     (hd0,5)
/dev/sdb7                   /home                 (hd0,6)
=======================================================================

Note that there is no /boot partition on the USB memory stick. As a consequence, the entries in menu.conf shall have /boot:

 kernel /boot/vmlinuz...

as opposed to entries for booting the OS on the hard drive which has /boot partition:

 kernel (hd1,4)/vmlinuz ... 

During the installation of the OS on the USB memory stick, or later during fixing the boot problems, create a file menu.lst in /boot/grub/ that has the following content:

===========================================================================
default 0
timeout 8
gfxmenu (hd0,5)/boot/message

title openSUSE 10.3 on USB stick (/ = sdb6)
   root (hd0,5)
   kernel /boot/vmlinuz-2.6.22.5-31-default \ 
     root=/dev/disk/by-id/usb-_USB_Flash_Memory_030942135147-0:0-part6 \
     resume=/dev/sdb5 splash=verbose showopts
   initrd /boot/initrd-2.6.22.5-31-default


title openSUSE 10.3 64 bit, on the hard drive (/ = sda6)
   kernel (hd1,4)/vmlinuz root=/dev/sda6 vga=0x314 \ 
     resume=/dev/sda9 splash=verbose showopts
   initrd (hd1,4)/initrd


title Windows Vista, on the hard drive
   rootnoverify (hd0,5)
   makeactive
   chainloader (hd1,0)+1
   map (hd0) (hd1)
   map (hd1) (hd0)


title Failsafe -- openSUSE 10.3 on USB stick (/ = sdb6) 
   root (hd0,5)
   kernel /boot/vmlinuz-2.6.22.5-31-default \ 
     root=/dev/disk/by-id/usb-_USB_Flash_Memory_030942135147-0:0-part6 \
     showopts ide=nodma apm=off acpi=off noresume edd=off  3
   initrd /boot/initrd-2.6.22.5-31-default
===========================================================================

Some clarifications. The statements like

 root (hd0,5)

in menu.conf do not refer to the root (/) partition - they refer to the /boot partition. (As if it was difficult to use, say, 'base (hd0,5)' in order to avoid additional confusion like the numbering of the partitons from 0 or 4 (in the extended container) creates. But for that, one needs ... - what does one need to begin counting things from 1, or not to use the same word with different meaning in the same text? Teachers? Brothers? Textbooks? Anyhow, isn't it good that they haven't begun counting things from -255 or even -256?) The requirement (and the reasoning behind it) for special mapping of the hard drives to boot Windows has been discussed elsewhere.

Two other important files to create, or to verify the content, are /etc/grub.conf with the following content:

setup --stage2=/boot/grub/stage2 (hd0) (hd0,4)
quit

and /boot/grub/device.map with the following content:

(hd1)   /dev/sda
(hd0)   /dev/sdb

The setting of the three files can be done in Yast during installation, or with an editor after, or in Yast after.

In Yast, some manual setting of the boot process is required. Go to the tab "Boot loader installation". In "Boot loader options", set active flag in partition table for boot partition. In "Boot loader location", select to boot from root partition. Finish in Yast, with watching for the blinking of the LED on the USB memory stick rather than the LED of the hard drive activity (mostly).

Now the booting of the three OSs should work. If not, then the probable reasons are unsuitable computer, wrong numbering, syntax errors. Editing lines at failed GRUB prompt with the primitive editing facility that is provided may be easy and helpful.



Important note: This configuration is not covered by the free installation support. However, you can make use of our advanced support service. See http://www.suse.de/en/private/support/inst_support/advanced.html for details.

de:SDB:Der Bootmanager GRUB