Click to See Complete Forum and Search --> : Multi booting in Linux explained


saikee
10-21-2007, 12:10 PM
This is what I hope to be a simple tutorial of booting 3 Linux of Ubuntu, Slackware and Mepis. The principle applies to 300 Linux if you got them.

A Linux is typically installed in a Ext2, Ext3 or Reiserfs partitions. The first track of such partitions is always reserved as the boot sector so that each partition can have a rightful residence for its boot loader.

If the partition is the first one in the hard disk its first sector of 512 bytes, commonly known as the MBR, is always read by the Bios for the booting purpose. Therefore we can have as many boot loaders as we want but only one of them get read by the Bios as the MBR. To put it in another way if I install 3 Linux I can only nominate just one Linux to control the MBR and relies on this boot loader to boot the other two.

A Linux can be installed in any primary or logical partition in a hard disk and can still control the booting process by sending its first sector of 512 byes to occupy the MBR. This is usually done automatically when you install the first Linux because it needed to be booted.

Your problem starts only when you install the second Linux.

The easiest way to install the second and more Linux is to tell each installer to keep its boot loader inside its root partition. That forces each Linux places its boot loader in the boot sector of the partition it resides. This makes the Linux immediately chainloadable by another boot loader, be it a Grub, a Lilo or even a MS boot loader.

A Linux, with a boot loader inside its root partition, cannot boot itself. It must be booted by a boot loader occupying the MBR. A Linux with access to the MBR can boot other Linux by two methods.


Direct method by entering into the partition to load the kernel and initrd
Indirect method by booting up another boot loader and let it do the work, a technique known as chainloading


To explain the above I use a Grub configuration file menu.lst of the first installed Ubuntu and color the additions in color. I have removed all the lines which are irrelevant to condense the print out
title Ubuntu 7.10 @ sda6 by direct booting
root (hd0,5)
kernel /boot/vmlinuz-2.6.22-14-generic root=UUID=80db91a1-b3f2-42b2-b3a2-9cb6e5f71b8b ro quiet splash
initrd /boot/initrd.img-2.6.22-14-generic

title Slackware 12 @ sda7 by direct booting
root (hd0,6)
kernel /boot/vmlinuz ro root=/dev/sda7

title Slackware 12 @ sda7 by chainloading
root (hd0,6)
chainloader +1

title MEPIS 6.0.4 @ sda8 by direct booting
root (hd0,7)
kernel /boot/vmlinuz root=/dev/sda8 nomce quiet vga=normal

title MEPIS 6.0.4 @ sda8 by chainloading
root (hd0,7)
chainloader +1
Any newbie wanting to multi-boot in Linux must be prepared to learn how to write the Direct booting instructions or the Indirect booting instructions but not both. The booting instruction for Grub is in /boot/grub/menu.lst but may be in /grub/menu.lst. grub.conf is used on Red Hat family distros. For Lilo it is always in /etc/lilo.conf.

You will see immediately that the Indirect method is simpler requiring you to know just the partition number, in Grub's notation, in which resides the Linux you wish to boot. You should also notice that Grub counts everything from 0 so the first disk is (hd0) and its 8th partition is (hd0,7), for example.

To boot a Linux by the Direct method requires you to know in advance the kernel name of the Linux, the kernel parameters to be passed on during boot time and the name of the ram disk file called "initrd.img". It so happens that I have picked the two easiest Linux that do not use initrd. Ubuntu, on the other hand, has a complicated kernel and initrd statement. Ubuntu is booting itself by the Direct method. This is always the case, , if its boot loader is occupying the MBR, because the Indirect method is just using one boot loader to boot another boot loader. The Indirect method does not work for Ubuntu because its Grub is already in the MBR, gets read by the Bios and will boot back to itself in a continuous loop.

Therefore if you boot 100 Linux you must have the one in the MBR booting itself directly and the rest of the 99 Linux booted indirectly. You could of course choose to boot every system directly but that is a lot harder when the number of system increases.

The the Indirect method does have the following advantages over the the Direct method


The original boot loader configuration, as created by the installer, is faithfully preserved.
The type of boot loader in each Linux is immaterial as the scheme works equally well for a Lilo or a Grub
It is a lot easier. The partition reference is the Linux.
The scheme requires the least amount of work.
It is very easy to switch boot loader in the MBR.
One can do relays with boot loaders, like one does 10 systems and its 10th Linux has a menu for the next 10 systems and so on.
Very complicated nested booting menu systems can be implemented.

To demonstrate I list the booting menu of Slackware which is a die-hard believer in Lilo. Its lilo.conf has been modified to boot Ubuntu and Mepis indirectly
# LILO configuration file in Slackware of sda7

boot = /dev/sda
message = /boot/boot_message.txt
prompt
timeout = 1200
# Override dangerous defaults that rewrite the partition table:
change-rules
reset
vga = 773

other = /dev/sda6
label = Ubuntu

image = /boot/vmlinuz
root = /dev/sda7
label = Slackware12
read-only

other = /dev/sda8
label = Mepis

Conclusion

When install the first Linux let its boot loader into the MBR.

From the second Linux onward tell the installer you want each boot loader to be place inside the root partition.

Amend the MBR's boot loader configuration file to boot other by chainloading

For Grub each additional Linux by inserting
title Linux in the (j+1)th partition of the (i+1)th disk
root (i,j)
chainloader +1
To chainload a Linux in partition sda7 with Lilo insert lines
other=/dev/sda7
label=Linux_sda7Lilo differs from Grub that each time its lilo.conf is altered then the command "lilo" must be issued to re-validate Lilo. Grub is easier as one can write all the booting choices in menu.lst even before the Linux are installed as Grub can be installed into a data-only partition without attached to a Linux.

--------------------------------------------------------

For more information see Just booting tips (http://www.justlinux.com/forum/showthread.php?t=144294)

dwr50
12-15-2007, 04:18 PM
If I'm Reading this right and I want to install ubuntu 7.04, kubuntu 7.10,LinuxMint4.0,gOS1.01,and Puppy Linux2.16.1, on the same drive, I should install Puppy first ?

stumbles
12-15-2007, 04:42 PM
I only wish the man pages were written so clearly.... nice work saikee. (http://justlinux.com/forum/member.php?u=60730)

saikee
12-15-2007, 08:15 PM
Things that worth to write always ending up too long and too much when I finish each one. I changed the tactic for the newbies forum by posting small bits and pieces which are short and can be easily read.

Just a small effort to help the newbies into Linux. Most the information aren't new but may be useful for the newcomers. Experienced Linux can always contribute by writing their own or point out improvements I could make to the thread.

Whatever I know I learn it in Justlinux.

dwr50
12-16-2007, 01:37 PM
I just partitioned my drive sda1 - sda12, and installed PCLinux2007. When I looked at my Grub menu.lst file I noticed it listed my drive partition as (hd0,4) . I was expecting (sda0,4) , why is this ?

Upon closer examination I see root=/dev/sda5
resume=/dev/sda6

so some things are being called sda... even more confusing.

bwkaz
12-16-2007, 03:23 PM
When I looked at my Grub menu.lst file I noticed it listed my drive partition as (hd0,4) . I was expecting (sda0,4) , why is this ? Couple reasons. First, your expectation is wrong: (sda0,4) would be the first sda disk (except that sda is already the first SCSI disk; you probably meant (sd0,4) instead). ;)

Second, GRUB doesn't use the OS's disk devices except when it installs itself -- when it's running (which is the only time the menu is used), it has its own notation. And that notation treats all disks equally: they're all (hdX), and their partitions are all (hdX,Y).

Upon closer examination I see root=/dev/sda5 resume=/dev/sda6 That's in the kernel command line. You use /dev names there because those parameters are interpreted either by the kernel or by an initramfs -- and both of those use the normal Linux device names. GRUB doesn't care what partition you tell your kernel to boot from, or resume from. :)

dwr50
12-16-2007, 05:03 PM
###############
# Grub menu.lst
###############
timeout 10
color black/cyan yellow/cyan
gfxmenu (hd0,4)/usr/share/gfxboot/themes/pclinuxos/boot/message
default 0

title PCLinux
kernel (hd0,4)/boot/vmlinuz BOOT_IMAGE=linux root=/dev/sda5 acpi=on resume=/dev/sda6 splash=silent vga=788
initrd (hd0,4)/boot/initrd.img

title linux-nonfb
kernel (hd0,4)/boot/vmlinuz BOOT_IMAGE=linux-nonfb root=/dev/sda5 acpi=on resume=/dev/sda6
initrd (hd0,4)/boot/initrd.img

title failsafe
kernel (hd0,4)/boot/vmlinuz BOOT_IMAGE=failsafe root=/dev/sda5 failsafe acpi=on resume=/dev/sda6
initrd (hd0,4)/boot/initrd.img

What does title linux-nonfb mean/do ?

I just figured out how to cut/paste and use Kjots to transfer screen info by pendrive to my Vista pc so I can post the info. The day hasn't been wasted.

saikee
12-16-2007, 09:28 PM
Each boot loader has to inform the user what system he/she is booting to. Grub does this by the title command.

Various video may be difficult to match and the "linux-nonfb" is another choice to tune to video if the default doesn't come out satisfactorily

dwr50
12-17-2007, 11:24 AM
Each boot loader has to inform the user what system he/she is booting to. Grub does this by the title command.

Various video may be difficult to match and the "linux-nonfb" is another choice to tune to video if the default doesn't come out satisfactorily

Do you mean the computer's monitor setup or are we talking divix, mpeg, ect.

saikee
12-17-2007, 11:57 AM
linux = the default kernel, with framebuffer support

linux-nonfb = the default kernel, without framebuffer support

failsafe = single user maintenance mode, but with the root filesystem
mounted read-only

There is a generic, "works on most every display" graphics interface called
the "frame buffer" interface. The "linux" boot will use this interface for
your graphics.

However, if your video card doesn't support framebuffer, OCLinuxOS, which is based on Mandrake, offers a way to boot using the video-card specific graphics support. The "linux nofb" option uses this video-card specific support.

The two options are provided so as to permit you to get a GUI up, no matter
what the graphics card.