Grub Setup for Multi-boot Linux

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
Eqwatz
Posts: 3
Joined: Sun 18 Mar 2007, 23:51

Grub Setup for Multi-boot Linux

#1 Post by Eqwatz »

I am writing this from a hard drive install of Puppy Linux which used the universal installer script found in the set-up menu from the desktop.
It was installed to it's own partition on a system which was already a multi-boot between Debian, Slack, and XP.

Grub should only be installed ONCE. This will give you your initial grub boot menu between [Your Other Distro] and XP.

The easiest means of adding other distros to your boot menu is to install them to their own partition--sharing the "swap" partition--then to "mount" the partition of your first installation and make your changes there manually.

Note: Although all of the "." files have made sharing "/home" and "/root" between the different distros to save space a problem, one can create empty directories in all of the respective /home directories and mount directories from a previously mounted partition to them. Just make the entries in the correct order in /etc/fstab so that all of the mount commands work properly. This way you can re-use downloaded sources and such in different distros to check the make and installation files. And create packages specific to each distro. Just remember to change owner and group to something generic after creation and download. Have fun. (Yeah, right.)

In Puppy Linux, you have the fabulous media manager, which will enable you to mount your other partitions easily.

Once you have mounted the partition with your default grub menu (of your previously installed distribution):
Open that distros /boot directory;
Make directories for each additional distribution you wish to add;
Then copy the Linux kernel and initrd.xxx files to the respective directory;
Then edit the grub/menu.lst to point to the kernel and initrd.
That's it.

To be specific:
Open mounted "/" for other distro;
Make puppy directory in /boot of that mounted filesystem;
Change desktop to see "home"; open your present filesystem; go up one level to "/"; go to /boot; copy "vmlinuz";
Paste into puppy directory on mounted partition "/boot/puppy";
Go back to "/boot" on your active system go up to "/" copy zdrv_214.sfs;
Paste that to your puppy directory in mounted filesystem;
Then edit the menu.lst in the mounted /boot/grub.

title Puppy Linux
root [same as above for other distro]
kernel /puppy/vmlinuz root=[partition you installed to] ro
initrd /puppy/zdrv_214.sfs
boot

The entry for my working system:
title Puppy Linux (on /dev/hde5)
root (hd0,1)
kernel /Puppy/vmlinuz root=/dev/hde5 ro
initrd /Puppy/zdrv_214.sfs
boot

There should be several spaces (or a tab) between the information in each entry and the name of the entry in the menu.lst file. Use the previous entries for a guide concerning the use of white-space.
Grub can look for and into other directories for the kernel and initrd files. Also, after loading into ram, the command "pivot_root" is called for installed Linux; at that point it is running from the partition to which you have installed the new distro (in this case puppy) and will read the configuration files in the native /boot and /etc directories along with the init-scripts.

The working example isn't going here because when I was writing this the page was changed, I lost all that I had written and "cut and paste" was disabled. I am not going to recreate by hand an entire /grub/menu.lst. You are free to complain to those responsible.
Eqwatz

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

Re: Grub Setup for Multi-boot Linux

#2 Post by Flash »

Eqwatz wrote:...The working example isn't going here because when I was writing this the page was changed, I lost all that I had written and "cut and paste" was disabled. I am not going to recreate by hand an entire /grub/menu.lst. You are free to complain to those responsible.
Eqwatz
Ooh, sorry. :( Your login must have timed out. If you're logged into the forum but don't do something for an hour, you aren't logged in anymore. It's happened to me, too. The best insurance is to do your writing in a separate application, such as "Edit" on the desktop (Geany text editor), then log into the forum and copy and paste your work from Geany to the forum. I know, it's easy to get into composing something and forget about the time. Won't you reconsider and give us an example? A good example is worth a thousand pictures. :)

Eqwatz
Posts: 3
Joined: Sun 18 Mar 2007, 23:51

A little more info.

#3 Post by Eqwatz »

First thing to know: I had to installl a /boot partition on the first HD of the system as the new Motherboard had a buggy SiS chipset. It refused to use a set-up which worked okay with the Intel and Via chipsets--ie having the first partition of the first hard drive marked as "active" or "bootable" by XP with the mbr pointing to the Debian "/" partition located on the second Hard Drive. I was too lazy to look up, and set up the scripts which would have "toggled the *boot flag on the XP partition everytime the system shut down. You will note that the boot script for grub always has the line "makeactive"--this is the command to "toggle" the *boot flag for a Windows installation.

When I copied the Debian /boot directory, I was tired and butchered the command. I was then just determined to get the system working and never got around to re-doing the /boot partition; so, it is still a mess. Here it is--warts and all.

/boot partition 1rst HD 2nd partition (hd0,1) or /dev/hdb2:
boot
config-2.6.8-3-k7
initrd.img-2.6.8-3-k7
lost+found
Puppy
slack
System.map-2.6.8-3-k7
vmlinuz-2.6.8-3-k7

[Why is there a boot directory in /boot? Because I buggered the command at 2:30am, that's why.]

/boot/boot :
config-2.6.8-2-386
grub
initrd.img-2.6.8-2-386
System.map-2.6.8-2-386
vmlinuz-2.6.8-2-386
[Ah, there it is.]

/boot/boot/grub:

default
device.map
device.map~
e2fs_stage1_5
fat_stage1_5
jfs_stage1_5
menu.lst
menu.lst~
minix_stage1_5
reiserfs_stage1_5
stage1
stage2
xfs_stage1_5

This is my system:
#$~: less /proc/partitions>/root/partitions.txt.
[Paste of /root/partitions.txt:]

major minor #blocks name

3 64 19932696 hdb
3 65 9904041 hdb1
3 66 64260 hdb2
3 67 1 hdb3
3 69 9960268 hdb5
22 0 120060864 hdc
22 1 61456 hdc1
22 2 11718504 hdc2
22 3 1 hdc3
22 5 9765976 hdc5
22 6 762016 hdc6
22 7 762016 hdc7
22 8 39062992 hdc8
22 9 57069400 hdc9
33 0 78150744 hde
33 1 22603423 hde1
33 2 506047 hde2
33 3 1 hde3
33 5 3301326 hde5
34 0 78150744 hdg
34 1 538177 hdg1
34 2 77610015 hdg2
56 0 156290904 hdi
56 1 156288321 hdi1
57 0 156290904 hdk
57 1 538146 hdk1
57 2 538177 hdk2
57 3 155211997 hdk3

Here is the working /boot/boot/grub/menu.lst:

# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 5

# Pretty colours
color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specifiv kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
# kopt=root=/dev/hdc2 ro

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,1)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery mode) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true

## ## End Default Options ##

title Debian GNU/Linux, kernel 2.6.8-3-k7
root (hd0,1)
kernel /vmlinuz-2.6.8-3-k7 root=/dev/hdc2 ro psmouse.proto=imps psmouse.resetafter=1
initrd /initrd.img-2.6.8-3-k7
savedefault
boot

title Debian GNU/Linux, kernel 2.6.8-3-k7 (recovery mode)
root (hd0,1)
kernel /vmlinuz-2.6.8-3-k7 root=/dev/hdc2 ro single
initrd /initrd.img-2.6.8-3-k7
savedefault
boot

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/hdb1
title Microsoft Windows XP Home Edition
root (hd0,0)
savedefault
makeactive
chainloader +1


title Slackware Linux, kernel vmlinuz-ide-2.4.31
root (hd0,1)
kernel /slack/vmlinuz-ide-2.4.31 root=/dev/hde1 ro
savedefault
boot

title Slackware Linux, Kernel k7-2.6.18
root (hd0,1)
kernel /slack/bzImage-k7-2.6.18 root=/dev/hde1 ro
savedefault
boot

title Slackware Linux, Kernel vmlinuz-2.6.18new
root (hd0,1)
kernel /slack/vmlinuz-2.6.18new root=/dev/hde1 ro
boot

title Puppy Linux (on /dev/hde5)
root (hd0,1)
kernel /Puppy/vmlinuz root=/dev/hde5 ro
initrd /Puppy/zdrv_214.sfs
boot

I did have more distros installed and booted but removed them to have more room for music before I upgraded the hard drives. There's 160GBs of music on /dev/hdi1.

PS: You can see that there is an entry for the original install kernel for Debian--which you can see resides in "/boot/boot" I never fixed that entry, as I had recompiled a kernel for the arch. that Debian was running upon. Lazy, yes; but you should be able to pick out the fact that that entry does not work from the grub boot-up menu. The working kernel, configuration, system.map all reside in the root of /boot. I hope that is clear.

BTW: As said before, the zdrv_214.sfs is an initrd; an initial ramdrive.
[edited for spelling. Edited a second time to add info.]

Eqwatz
Posts: 3
Joined: Sun 18 Mar 2007, 23:51

One more thing

#4 Post by Eqwatz »

If you change hard drives or their location/order in the system, you need to edit the device.map file in the /grub directory. Although I'm not sure that it is necessary unless you are using the "remap drives" options in grub to avoid having to use a /boot partition on the first hard drive (and have left the bios in their default setting; which has it attempt to boot from the first hard drive.)

In the end, everything comes down to the bios, and what they are capable of doing.

Yes, you can use grub-update with the "target" and other options to "auto-magically" update your /boot/grub/menu.lst if located upon another drive/partition. It gets complicated very quickly, and I will absolutely botch it up every time. That is why I always do it manually.
If I screw it up, I only screw up one of the entries--rather than buggering up the entire thing.

There is another alternative if you have multiple drives on a newer computer with the more sophisticated bios.
You leave the Windows drive alone. Don't install grub to the MBR of the first drive at all. Put your Linux distros on the second drive; load grub into THAT drive's MBR--and set the bios to boot from the second drive. This means that you never have to worry about losing what ever is on the first drive. You just have to remember how you set the bios if anything goes wrong--or write a short log inside the computer case with that information.

But again with that scenario, things can get complicated with grub as the bios is swapping drive identifications just like the grub "remap drives" option. In my case, I would always get confused and do something stupid sometime very late at night--rendering the machine to "boat anchor" status until I had time to straighten it out. Your milage will vary.

Eqwatz

[Edited to add more info.]

Post Reply