LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-03-2006, 03:06 AM   #1
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Rep: Reputation: 15
Switching Distro and Grub


Hi all,

Currently i have two NTFS partitions (for MS stuffs), one VFAT partition (for shared files), and a number of EXT3 and ReiserFS partitions (for Ubuntu).

Using Grub, i'm currently able to select Ubuntu or XP (or memtest86) on booting up.

i intend to re-organize the Linux partitions (currently have too many), and also leave some space for a second distro (for times when i want to experiment an alternative distro).

Question is, when i "remove" a distro (through re-partitioning or formatting) or when i add a distro, do i need to re-configure Grub manually to reflect the changes? Any advise on how i can do that properly? (i don't wish to end up with an un-bootable system. )

My (logical) guess is that when a distro is "removed" the corresponding entry has to be removed from Grub manually, but when a distro is "added", the installation process will modify the existing bootloader configurations to add the corresponding entry. Is that correct? In that case, how can i properly remove the defunct entries from Grub?



TIA and Regards,
Edwin
 
Old 06-03-2006, 03:32 AM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
When you add or remove distros on your system you need to edit /boot/grub/menu.lst and remove or add entries for that distro. The only problem with adding a new distro is that you may not know what the kernel and initrd image are called, so I tend to mount the new distros root (/) partition and take a look in its /boot partition so that I have the correct details when making the entry.
 
Old 06-03-2006, 05:21 AM   #3
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Original Poster
Rep: Reputation: 15

Hi,

i just looked through menu.lst, and have a few more questions:

1) Does that mean that, even if i have two different distros installed, they should "share" a common "/boot"? (Otherwise, it'll end up with two different copies of "/boot/grub/menu.lst"?)



2) i see references to files on in the "/boot" directory:
Code:
kernel   /vmlinuz-2.6.12-10-386 root=/dev/hda7 ro quiet splash
initrd   /initrd.img-2.6.12-10-386
i suppose when i install a distro, it will drop these files into the "/boot" directory. In that case, if i have two different distros sharing a "/boot", will there be a "danger" of files being overwritten?



3) It is correct to specify "/vmlinuz-2.6.12-10-386" and "/initrd.img-2.6.12-10-386" even though those files are actually located in "/boot/vmlinuz-2.6.12-10-386" and "/boot/initrd.img-2.6.12-10-386"?



4)
Code:
root   (hd0,5)
(hd0,5) means hda6 which is the mount point "/boot"?



5)
Code:
kernel   /vmlinuz-2.6.12-10-386 root=/dev/hda7 ro quiet splash
/dev/hda7 points to the mount point "/"?



6) This is not really relevant, but i just would like to understand more:
Code:
title         Microsoft Windows XP Professional
root          (hd0,0)
savedefault
makeactive
chainloader   +1
What do "savedefault", "makeactive" and "chainloader +1" mean?



Thanks and Regards,
Edwin

Last edited by edwin11; 06-03-2006 at 05:22 AM.
 
Old 06-03-2006, 05:36 AM   #4
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Kind of a chicken and egg situation here.

Grub needs a partition to reside in and so removing Ubuntu will destroy Grub's home and remove its stage2 file rendering Grub without any intelligence.

The easiest way out of it is to restore MS's MBR, using a bootable DOS 6 or above floppy or XP's installation CD (Task B1 or B2 of the last link in my signature refers).

Once XP boots normally without the assistance of Grub you can use its disk management program to remove all the Ubuntu partitions, resize the XP (may need Partition Magic or do it with a Linux Live CD with QTParted program) and install other distros as you wish.

For new comers it is sensible to arrange one partition per Linux, typically 5Gb or 10Gb for a few large distros. The first one needs a swap partition too and 1Gb should work in all cases. It is also a good idea to have a data only partition in fat32 type so that all systems can read and write on it.

When you install a Linux it should arrange booting XP automatically for you. Thereafter additional Linux may need editing the /boot/grub/menu.lst if you use Grub or /etc/lilo.conf if you opt for Lilo in the MBR.

savedefault = use the last booting choice for the next boot up
makeactive = make the current partition active or bootable (needs only by xp)
chainloader +1 = load the partition at the +1 sector, thereby omitting the first 512 bytes.

The chainloader is to instruct Grub, currently sitting in the memory with stage1 and stage2 files to discard itself except the stage1 (512 bytes large) and "cut and paste" with the next system to be booted. It is the simplest and the most powerful technique in multi-boooting and has enabled Grub to boot every operating system that complies with the PC standard. Lilo uses the same technique. XP's NTLRD does it in similar way but as its NTLDR has to be compatible with DOS and older Windows it has to load the next system at +0 position and not +1 position.

Last edited by saikee; 06-03-2006 at 05:46 AM.
 
Old 06-03-2006, 06:14 AM   #5
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Original Poster
Rep: Reputation: 15
Thanks saikee,

Quote:
Originally Posted by saikee
Kind of a chicken and egg situation here.

Grub needs a partition to reside in and so removing Ubuntu will destroy Grub's home and remove its stage2 file rendering Grub without any intelligence.

The easiest way out of it is to restore MS's MBR, using a bootable DOS 6 or above floppy or XP's installation CD (Task B1 or B2 of the last link in my signature refers).

Once XP boots normally without the assistance of Grub you can use its disk management program to remove all the Ubuntu partitions, resize the XP (may need Partition Magic or do it with a Linux Live CD with QTParted program) and install other distros as you wish.
i don't intend to resize the NTFS and VFAT partitions. Can i just use a distro's installer CD to bootup, delete and re-create the EXT3 and ReiserFS partitions, then install the distro there and then?

Quote:
Originally Posted by saikee
For new comers it is sensible to arrange one partition per Linux, typically 5Gb or 10Gb for a few large distros.
i would still like to have different partitions for e.g. "/var", "/home", etc. i suppose i can have it such that if i boot up to distro A, one partition is mounted on "/var", but when i boot to distro B, another partition gets mounted on "/var" instead?

Quote:
Originally Posted by saikee
The first one needs a swap partition too and 1Gb should work in all cases.
Erm... "The first one"?

Quote:
Originally Posted by saikee
When you install a Linux it should arrange booting XP automatically for you. Thereafter additional Linux may need editing the /boot/grub/menu.lst if you use Grub or /etc/lilo.conf if you opt for Lilo in the MBR.
Does that mean that "/boot" will be common across the two distros, the necessary files "vmlinuz-2.6.12-10-386", "initrd.img-2.6.12-10-386", etc will be automatically placed there even for the second distro, but i'll have to edit the menu.lst?



Thanks and Regards,
Edwin
 
Old 06-03-2006, 07:17 AM   #6
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Some installation CDs go straight into the installation mode and would not entertain you as a Live CD. So if your installation CD is an installable Live CD then by all mean.

The reason I advise a single partition per Linux is to avoid the a user to mix more than one distro information in /boot, /var, /home .... Unless you are pretty good at tracking the various files by using /boot, /var etc common to several Linux you will eventually end up with more panics than you know how to deal with them. Putting them in each own partition wastes very little but is a lot easier to maintain. At the end of the day it is up to you to arrange it. I couldn't possibly install 100+ systems in my box with a common /boot simple because many distros use the same file name "vmlinuz" for the kernal names (e.g Slackware family), even though the kernel may be from different versions.

If you installing Linux for the first time you need to have a Swap partition available. Subsequently all later Linux will use the same swap and no need to create any more.

If you choose to house each Linux in its own single partition every distro's /boot directory will have a full set of the original kernel and initrd files plus the original boot loader configured by the installer. You are then free to select any one of the Linux to occupy the MBR position for multibooting the rest of the operating systems. This is by editing the /boot/grub/menu.lst in Suse's partition in your case. If you select a Lilo to multiboot in the MBR it will be its /etc/lilo.conf file you need to edit.

In general you can get inside any unbootable Linux by first boot to a Live CD, make a temporary partition to mount the unbootable Linux and then change root to it.

After the "chroot" command you would be inside the unbootable Linux (more accurately you are using the kernel of the LiveCD in the Bash shell of the unbootable Linux).

In such a case and for Suse you can do a grub-install for any of the following combinations
Code:
grub-install /dev/fd0
grub-install /dev/hda
grub-install /dev/hda1
The first install Grub into a bootable floppy so that Suse can be booted without using the MBR from a hard disk.
The second is the put Suse's Grub into the MBR of disk hda. Thay makes Suse to control the bootingn if hda is the first bootable disk.
The last is to put Grub inside partition hda1 (assuming it is where Suse resides). This permit Suse to be booted by a second Linux.

In conslusion you can choose any Grub ( or any Lilo or to a lesser extent Windows' NTLDR) to multi boot.
 
Old 06-03-2006, 11:12 AM   #7
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Original Poster
Rep: Reputation: 15
Hi, thanks for taking the time to explain all these, i really appreciate it. Things are a lot clearer now, but i think there's still one thing i'm not clear.

Quote:
Originally Posted by saikee
The reason I advise a single partition per Linux is to avoid the a user to mix more than one distro information in /boot, /var, /home .... Unless you are pretty good at tracking the various files by using /boot, /var etc common to several Linux you will eventually end up with more panics than you know how to deal with them.
No, i don't mean having the different partitions share a "/var" or even a "/home". What i meant is, e.g. i'll have /hda5 for "/var" for distro 1, and /hda6 for "/var" for distro 2. When i boot to distro 1, /hda5 will be mounted to "/var", and /hda6 will not be mounted, and vice-versa when i boot to distro 2.

Quote:
Originally Posted by saikee
I couldn't possibly install 100+ systems in my box with a common /boot simple because many distros use the same file name "vmlinuz" for the kernal names (e.g Slackware family), even though the kernel may be from different versions.
Understood... that means a different "/boot" for each distro.

Quote:
Originally Posted by saikee
If you installing Linux for the first time you need to have a Swap partition available. Subsequently all later Linux will use the same swap and no need to create any more.
Understood... Only need one swap partition, and all distros will "share" thos one.

Quote:
Originally Posted by saikee
If you choose to house each Linux in its own single partition every distro's /boot directory will have a full set of the original kernel and initrd files plus the original boot loader configured by the installer. You are then free to select any one of the Linux to occupy the MBR position for multibooting the rest of the operating systems. This is by editing the /boot/grub/menu.lst in Suse's partition in your case.
This is the part where i still don't quite understand. Now we've established that each distro has its own "/boot". And assuming both uses Grub, that means each distro has its own "/boot/grub/menu.lst". What mechanism determines which "/boot/grub/menu.1st" gets used on boot up? i.e. if i understand correctly, How do i select a bootloader to occupy the MBR?



Thanks and Regards,
Edwin
 
Old 06-03-2006, 11:40 AM   #8
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
In a single partition installation /boot, /var, /home.... etc are all subdirectories to "/". If you have 10 Linux installed you have 10 set of them.

If you store you personal data in a fat32 partition, which can be read/write by any system, then none of the Linux subdirectories will grow much or out of control.

Once /boot, /var, /etc, /home... are part of the directory tree you are free from the problem of having the partition exceeded individually in size because everything is in one large partition. The filled portion is simply self expanding and contracting all the time.

I thought I have explained reasonably well on how to choose which Linux to go into the MBR. You are just puzzled by how the PC knows which partition to boot.

If you ever examined Lilo's lilo.conf you will find its booting commands look like the following
Code:
root=/dev/hda10
image=/boot/vmlinux-2.6.12
label="Knoppix"
initrd=/boot/initrd.img-2.6.12
for Grub the equivalent would be
Code:
title Knoppix 
root (hd0,9)
kernel /boot/vmlinux-2.6.12
initrd /boot/initrd.img-2.6.12
It should be clear to you that in every Linux boot loader the first command is always to "identify" the root or "/" of the Linux. Effectively the partition is declared before anything is done.

Therefore if you put any Grub from a Linux into the MBR it has to boot its parent partition! Thereafter you can edit this /boot/grub/menu.lst to include or exclude the booting of other systems.

In fact Grub (or Lilo) only load itself up first and wait for a period specified in the "timeout" statement before defaulting to the system specified by the "default" statement. Therefore a Linux user simply puts Linux A's Grub into the MBR. From Linux A's Grub he/she can boot to Linux B's Grub, from there he/she can hoop to Linux C's Lilo and so on and so forth without selecting a system to boot to for as long as he/she wishes.

Such are the endless possibilities one can play around with Linux's boot loaders. As you expect you can mix it with Windows NTLRD too but it is a lot more rigid and so less versatile to play around with.

Last edited by saikee; 06-03-2006 at 11:43 AM.
 
Old 06-03-2006, 11:44 PM   #9
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Original Poster
Rep: Reputation: 15
Hi,

Quote:
Originally Posted by saikee
I thought I have explained reasonably well on how to choose which Linux to go into the MBR. You are just puzzled by how the PC knows which partition to boot.

Therefore if you put any Grub from a Linux into the MBR it has to boot its parent partition! Thereafter you can edit this /boot/grub/menu.lst to include or exclude the booting of other systems.
OK, i kind of understand this part, and to put a distro's Grub into the MBR, we use "grub-install /dev/hda" right?

i'm still not that clear on how "grub-install" works, and i've tried reading the links in your sig, as well as the Grub man page and the Grub manual.

What does "grub-install /dev/hda" or "grub-install /dev/hda5" actually do?

In one of the links in your sig (http://www.justlinux.com/forum/showt...hreadid=134658), you have
Quote:
(d) Replicate the bootloader in root partition (“grub-install /dev/hda7”)
and
Quote:
(i) Restore hda6’s bootloader in MBR (“grub-install /dev/hda”)
i understand the second one, because we have "chroot-ed" to the root of the first installed distro, by doing "grub-install /dev/hda" there and then, we are "copying" the Grub of the first installed distro (plus the changes) to the MBR.

But i don't understand the first one. At that time we are booted into the second distro, whose root is "/dev/hda7", so by doing "grub-install /dev/hda7", aren't we "copying" the Grub of the second installed distro to itself again?



Thanks and Regards,
Edwin
 
Old 06-04-2006, 10:00 AM   #10
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Say if you have 3 Linux in hda1, hda2 and hda3.

You decide to nominate hda1 into the MBR and aftering "chroot" into it the command "grub-install /dev/hda" instructs Grub to install itself into raw device /dev/hda. Since no partition reference is given Grub takes it for the whole disk and put it in the MBR. As Grub has been sourced from hda1 it would be that version of Grub being installed into the MBR and not the one from hda2 or hda3. Hope it is clear so far.

To boot hda2 and hda3 by the Grub in hda1, which has occupied the MBR by now, there are two methods; direct and indirect methods.

For the direct method you need to boot hda2 or hda3 by calling its kernel and initrd files. That is the traditional way. It is exactly the way how hda1 is booted so take a look at the menu.lst.

In the indirect method, which I favour, you chainload hda2 and hda3 using the technique identical to the way a Windows is booted, namely with only 3 lines
Code:
title My Linux in hda2
root (hd0,1)
chainloader +1
You will notice that in the indirect method the key inofrmation is the root statement. As Grub counts from 0 and so (hd0,1) is hda2. Similarly you repeat the above 3 lines for booting hda3 excepting changing the root reference to (hd0,2).

In order to use the indirect method a boot loader must be available inside the root partition of the Linux. Therefore you must chroot to hda2 to do a "grub-install /dev/hda2" and similarly for hda3 with "grub-install /dev/hda3".

That should explain the use of the two grub-install statements I hope.

The power of indirect method is you can use Grub to boot a LInux with Lilo boot loader. Say if hda3 has Lilo then the command corresponding to "grub-install /dev/hda3" is "lilo -b /dev/hda3" to install Lilo in hda3 root partition.

You can use indirect method to boot any OS in a PC, using the same 3 lines but differing only the reference in the root statement in Grub. The title statement is unimportant as it is just a line appear in the menu to tell you what that partition is. In the indirect method you boot from one boot loader to another.

The commands inside menu.lst are Grub's own commands. "grub-install" and "lilo -b" are Linux commands and so the same raw device to Grub as hd0,0) will appear in Linux as hda1.
 
Old 06-04-2006, 09:15 PM   #11
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Original Poster
Rep: Reputation: 15
Its getting very clear now, thanks very much! Just a couple of questions:



1.
- Say the situation is that i already have XP installed on another partition (/dev/hdb).
- When i install distro1 (in /dev/hda1), it sets up Grub for me such that the menu.lst contains two items: distro1 and XP, and places this Grub in hda MBR.
- Then i install distro2 (in /dev/hda2), it also sets up Grub for me such that the menu.lst contains two items: distro2 and XP, and overwrites hda MBR with its Grub.
- Now i boot into distro2, do a "grub-install /dev/hda2".
- Mount /dev/hda1, and modify its menu.lst to add an entry for distro2 (using the indirect "chainloader +1" method)
- chroot to distro1, and do a "grub-install /dev/hda".

Won't i get the following situation when i boot up:
- i'll first see a menu with three items (distro1, distro2, XP).
- if i choose distro1, it'll start distro1.
- if i choose distro2, i'll see another menu containing two items (distro2, XP)
?



2. Why do you favour the indirect method over the direct one?



Thanks and Regards,
Edwin

Last edited by edwin11; 06-04-2006 at 09:17 PM.
 
Old 06-05-2006, 05:39 AM   #12
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
I have already answered your Question (1) before you asked by the second last para of my previous post
Quote:
You can use indirect method to boot any OS in a PC, using the same 3 lines but differing only the reference in the root statement in Grub. The title statement is unimportant as it is just a line appear in the menu to tell you what that partition is. In the indirect method you boot from one boot loader to another.
You can get an instant booting to hda2 from hda1 by reducing the timeout statement of /boot/grub/menu.lst in hda2 and set the default statement to boot hda2 and not Xp.

The answer to Question (2)

The indirect booting has the following adavantages

(1) The original boot loader as created by the installer is kept intact so that you can always go back to boot it directly if you so wish.
(2) The distro is instantly suitable for chainloaded by any non-Linux boot loader, say NTLRD of XP which need the first 512 bytes from its root partition.
(3) You don't need to know or to supply the kernel and initrd names for every distro.
(4) You boot the distro with the same command regardless if it use Grub or Lilo.
(5) You can use only one method, with commands so simple that nothing is needed to remember, to boot all other systems of Dos, Windows, Linux, Darwinx86, BSD and Solaris.
(6) In direct booting you need to load the kernel with parameters specific to that distro. Hence you have to be pretty precise with what you type in the Grub commands or do a "copy and paste" straight from another menu.lst. Also you have to be pretty good in converting the Lilo's instructions into Grub commands. Indirect booting looks after all of them for you and is fit for a lazy person like me, who happens to believe "if God does mind us to be lazy (for trying to do the minimum) he wouldn't have let us invent the computer".

In case I haven't stated clear the parent Linux is always booted "directly". To indirectly boot the parent Linux ( or the first Linux to be booted) will end you up like a dog chasing its own tail or an endless loop.

Last edited by saikee; 06-05-2006 at 05:41 AM.
 
Old 06-05-2006, 08:56 AM   #13
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Original Poster
Rep: Reputation: 15
It all makes perfect sense now! Thanks for your patience and time!



Regards,
Edwin
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Switching from ubuntu to another distro, which one? mandrakethepenguin Linux - General 5 04-01-2006 08:12 PM
Switching to Linux- Which Distro? losslesshead Linux - Newbie 13 10-27-2005 04:22 AM
switching distro zer0s0pht Linux - General 4 07-23-2004 05:48 AM
Need advice on switching distro... Toker Linux - Newbie 15 03-26-2004 04:00 PM
Switching to new Distro from RH8 arobinson74 Linux - Distributions 2 01-03-2004 09:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration