LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-08-2008, 04:20 AM   #1
Tomermory
Member
 
Registered: Mar 2007
Location: Amiens, France
Distribution: Debian Etch,
Posts: 181

Rep: Reputation: 30
Installing a second Linux distro: what to do about Grub?


Hello,

After a year using Debian (and being very happy with it) I want to experiment with Arch Linux and/or Gentoo as I'm no longer learning anything with Debian. However, I want to keep Debian going, at least for the time being, as my wife will probably freak out if I remove it! So I thought of installing my second system in a separate partition to create a dual-boot machine. That way I can experiment as much as I want with no risk, at least that's what I hope! Now, I know this is possible, but I believe that Grub needs to be set up in / and not in the MBR, which I think is where I put it. So the question is, what do I need to do to Grub? I imagine I should move it from the MBR to /, but how do I do this safely?

Here is the relevant part of my menu.lst file, as it is at present:

Code:
title		Debian GNU/Linux, kernel 2.6.25
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.25 root=/dev/hda1 ro 
initrd		/boot/initrd.img-2.6.25
savedefault

title		Debian GNU/Linux, kernel 2.6.25 (single-user mode)
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.25 root=/dev/hda1 ro single
initrd		/boot/initrd.img-2.6.25
And, if it helps, here is the result of fdsik -l:

Code:
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        9446    75874963+  83  Linux
/dev/hda2            9447        9729     2273197+   5  Extended
/dev/hda5            9447        9729     2273166   82  Linux swap / Solaris

Thanks very much for any help.

James
 
Old 05-08-2008, 04:35 AM   #2
MoonMind
Member
 
Registered: May 2005
Location: Switzerland
Distribution: Ubuntu
Posts: 448

Rep: Reputation: 38
You can use Gparted to resize /dev/hda1, then created a new partition and format it to ext3 (the last step's optional). Depending on the name of the partition, you might have to adapt GRUB's menu later (/dev/hda3 will become hd(0,2) in GRUB). Usually, if you install a new distribution, it should simply update GRUB, not overwrite it, but I can't tell you how Arch will behave. If in doubt, direct Arch's GRUB installation to the partition (instead of the MBR) and then adapt the GRUB installation you have.

I'd first go for automatic, but read Arch's available documentation in order to find out what'll happen to a previous GRUB installation. If there's a considerable chance it'll get overwritten, choose not to touch the MBR, or you'll have to reconstruct everything.

If the installation is successful, the rest is a bit of copy & paste in /boot/grub/menu.lst (on /dev/hda1!), followed by some careful editing... as long as you don't delete anything in that file, you can edit it without any problems until it works. The documentation available on this online is excellent.

M.

Last edited by MoonMind; 05-08-2008 at 04:38 AM.
 
Old 05-08-2008, 05:20 AM   #3
Tomermory
Member
 
Registered: Mar 2007
Location: Amiens, France
Distribution: Debian Etch,
Posts: 181

Original Poster
Rep: Reputation: 30
Thank you very much for this quick and clear reply.
I guess that's pretty well what I was thinking myself. But, and this might sound like a stupid question, if I set Grub up in the root partition of Arch and not overwrite the MBR, that'll mean I'll have Grub twice, no? I mean, how does it deal with that? Is this what you mean when you say:
Quote:
Usually, if you install a new distribution, it should simply update GRUB, not overwrite it
Quote:
read Arch's available documentation in order to find out what'll happen to a previous GRUB installation.
Yes, I have done this already but there's nothing on this. Brilliant documentation, though!
 
Old 05-08-2008, 08:15 AM   #4
Larry Webb
LQ Veteran
 
Registered: Jul 2006
Location: Crystal Beach, Texas
Distribution: Suse for mail +
Posts: 5,100
Blog Entries: 7

Rep: Reputation: 229Reputation: 229Reputation: 229
How you install grub with your Arch will depend on which distro controls the mbr. If when you install Arch you put grub in the root partition then the mbr will still point to Debian and you will have to update your /boot/grub/menu.lst in Debian in order to have Arch as a boot option. If you when you install Arch you install grub to the mbr it will point grub to boot to Arch. This I am not familiar with on Arch but it should pickup your Debian and add it to your menu.lst in Arch. If the later is true and you choose this the only concern is it will load Arch by default with about a 10 sec. timer. This you can change by editing your menu.lst to load Debian and change the number of seconds.
 
Old 05-08-2008, 08:25 AM   #5
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Installing a second Linux distro: what to do about Grub?

The answer is: nothing.

Do not install GRUB with your second, third, fourth ... distro. Just add a section to your existing GRUB configuration file to boot them.
 
Old 05-08-2008, 12:18 PM   #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
Below is the best kept booting secret in Linux for multi booting.

If a user wants to install another Linux in say partition (hd0,5) all it needs to do is to tell the installer to put Grub (or Lilo) inside the root partition or (hd0,5). Then on completion this Linux will fire up as clockwork if the following lines are in the menu.lst of Grub controlling the MBR
Code:
title Linux in in partition (hd0,5)
root (hd0,5)
chainloader +1
It works for every Linux from 2nd to the 200th.

It works for every operating system too, BSD, Solaris, Dos and Windows. Every Dos and Windows installer puts its boot loader in its root partition by default. It just doesn't tell its owner. That is all.

The above is all one needs to know to boot as many systems as one can install in a pC. There is nothing to it.
 
Old 05-08-2008, 12:56 PM   #7
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
And what might be the advantage to chainload multiple GRUB-s?
GRUB is not a part of Linux. It is GRand Unified Bootloader, you need just one of them to boot as many operating systems you like. None of them has to be Linux.
 
Old 05-08-2008, 01:36 PM   #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
OK

If you use kernel and inird statements to boot a Linux you boot it "directly".

If you use Grub from Linux A to "chainload" Linux B you only boot its boot loader and let Linux B's boot loader to boot its master. That is "indirect" booting. It is totally legal as writen and explained in Grub Manual.

Grub can't boot a system unless it has a kernel and inside a partition Grub can read. With chainloading Grub can boot any operating system including those inside partitions Grub cannot read.

The point is "indirectly" booting works for any PC operating system I have come across. It is simpler and the original boot loader is preserved. A Linux with Lilo is booted exactly the same as one with Grub and you never even need to know the names of its kernel or its initrd.

It boots every PC system like a hot wire cutting a piece of butter.

Both direct and indirect bootings are just tools that we can use. Lilo does it exactly the same. You just choose the tool that you are happy with.

I use chainloading a lot because it is a lot easier to resolve a booting problem when giving advice to others.
 
Old 05-08-2008, 02:05 PM   #9
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
I see your point. Agreed.
Sorry, I was thinking in my own terms, I think booting without initrd and using one bootloader is simpler.
 
Old 05-08-2008, 02:17 PM   #10
Tomermory
Member
 
Registered: Mar 2007
Location: Amiens, France
Distribution: Debian Etch,
Posts: 181

Original Poster
Rep: Reputation: 30
Thanks very much for the replies guys. I set out to learn something by installing Arch or Gentoo, and it's already started! The idea of using a chainloader is very interesting saikee, I'd like to use this method. However, I hesitate about the initrd part. I compile a custom kernel for this Etch box, but when I've forgotten to make the initrd.img, the computer refuses to boot. Does this mean that your method wouldn't work on my particular machine. Also, if I decide to delete Archlinux and to restore my box as 100% Debian, or change to dual boot it with Gentoo, would there be any conflicts or any other such issue?

Edit: And what about the opposite: I mean, if I decide to delete Debian and keep Arch?

Last edited by Tomermory; 05-08-2008 at 03:25 PM.
 
Old 05-08-2008, 03:40 PM   #11
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
Tomermory,

I believe each Linux has a couple of kernel and matching initrd files in the /boot directory. Thus if you didn't get your own version done can you use a pair supplied by the distro?

The booting got nothing to do with the initrd file. The initrd is the way you specify how the Linux is booted. That comes only after Grub has handed over the control to the kernel. Thus you should look at it in two stages. A bad or missing initrd affects only the 2nd stage. Grub only handles the 1st stage. Thus a bad initrd is not a problem Grub can solve.

If you have told the 2nd Linux installer to install the boot loader in its root partition then the original boot loader and its configuration file will be untouched for as long as you want it. In fact you can retrospectively put any Grub back into its own partition by command in a Grub shell
Code:
root (hd0,5)
setup (hd0,5)
The above tells Grub to pick the system files from partition of (hd0,5) and install itself into the boot sector of that partition, thereby making the distro permanently chainloadable.

Most partition types have the first track set aside as the boot sector. Putting Grub in its own partition is make use of that reserved track which can not be used for any other purpose. A few odd partition types donot have a boot sector.
 
Old 05-09-2008, 09:08 AM   #12
Tomermory
Member
 
Registered: Mar 2007
Location: Amiens, France
Distribution: Debian Etch,
Posts: 181

Original Poster
Rep: Reputation: 30
Thanks for all your help guys! I successfully installed Arch, although I had a few problems along the way - mostly due to silly mistakes. Actually, I was very impressed with this install. Very fast (when you don't cock up!) and configurable. Great stuff! Can't wait to get stuck in!
Saikee, your chainloader method worked a treat! I reckon that's the best way to do it as when I take off one of the Operating systems it'll be a snap! I did try the other methods too, like pointing the original Grub on the MBR to boot up Arch on the second partition, but I couldn't get it to work.
Anyway, thanks again for all your help. This has been a very educational experience!
 
Old 05-09-2008, 08:53 PM   #13
Frank64
Member
 
Registered: Feb 2008
Distribution: Kubuntu 19.10
Posts: 77

Rep: Reputation: 15
Quote:
Originally Posted by Emerson View Post
Installing a second Linux distro: what to do about Grub?

The answer is: nothing.

Do not install GRUB with your second, third, fourth ... distro. Just add a section to your existing GRUB configuration file to boot them.
Sorry to revive this thread (not that old! but sorta closed), but does all this also apply when installing a second distro on a SECOND HDD? I get GRUB error 2 (Bad file or directory type. This error is returned if a file requested is not a regular file, but something like a symbolic link, directory, or FIFO.) while trying to load the kernel of the second HD, but if I swap my HDs or if I remove my first HD, it will boot no problem.

I have tried not installing GRUB at all on the second HD/distro or installing it in its MBR, and I get same results.

Should I try to chainload?

I currently have opensuse 10.3 on (hd0,0) with GRUB in MBR. Then on (hd1,0) I have opensuse 11.0 with GRUB in MBR.

My menu.lst of (hd0,0) is:

Code:
# Modified by YaST2. Last modification on Sun Mar 23 12:26:54 EDT 2008
default 0
timeout 2
##YaST - generic_mbr
gfxmenu (hd0,0)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 10.3
    root (hd0,0)
    kernel /boot/vmlinuz-2.6.22.5-31-default root=/dev/sda1 vga=0x317 resume=/dev/sda5 splash=silent showopts
    initrd /boot/initrd-2.6.22.5-31-default

###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 11.0 - External drive
    root (hd1,0)
    kernel /boot/vmlinuz-2.6.25-26-default root=/dev/disk/by-id/scsi-SATA_ST3500320AS_5QM0PP7M-part1 resume=/dev/sda5 splash=silent showopts vga=0x31a
    initrd /boot/initrd-2.6.25-26-default

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 10.3
    root (hd0,0)
    kernel /boot/vmlinuz-2.6.22.5-31-default root=/dev/sda1 vga=normal showopts ide=nodma apm=off acpi=off noresume edd=off 3
    initrd /boot/initrd-2.6.22.5-31-default

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 11.0 - External drive
    root (hd1,0)
    kernel /boot/vmlinuz-2.6.25-26-default root=/dev/disk/by-id/scsi-SATA_ST3500320AS_5QM0PP7M-part1 vga=normal showopts ide=nodma apm=off acpi=off noresume edd=off 3
    initrd /boot/initrd-2.6.25-26-default
opensuse 11.0 never boots if I try from the menu.lst of (hd0,0).

tnx

Last edited by Frank64; 05-09-2008 at 09:03 PM.
 
Old 05-10-2008, 03:55 AM   #14
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
If Grub reports no error when you swap the hard disks then you should pay attention to the lines below marked in red
Code:
# Modified by YaST2. Last modification on Sun Mar 23 12:26:54 EDT 2008
default 0
timeout 2
##YaST - generic_mbr
gfxmenu (hd0,0)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 10.3
    root (hd0,0)
    kernel /boot/vmlinuz-2.6.22.5-31-default root=/dev/sda1 vga=0x317 resume=/dev/sda5 splash=silent showopts
    initrd /boot/initrd-2.6.22.5-31-default

###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 11.0 - External drive
    root (hd1,0)
    kernel /boot/vmlinuz-2.6.25-26-default root=/dev/disk/by-id/scsi-SATA_ST3500320AS_5QM0PP7M-part1 resume=/dev/sda5 splash=silent showopts vga=0x31a
    initrd /boot/initrd-2.6.25-26-default
This line "gfxmenu (hd0,0)/boot/message" instructs Grub to load the graphic menu available in (hd0,0) so If you present a wrong disk Grub will not be able to load the file and stuck there.

Your Suse 10.3 will boot if it is (hd0) and physically connected to the first Sata port of the mobo (in order to get detected first and received the sda designation).

Your Suse 11.0 can be placed physically in any Sata connection point but it must be on the first partition of hard disk identified in your PC as device SATA_ST3500320AS_5QM0PP7M

If you give all the things Grub can find then you will never have a booting problem.

I recommend putting a "#" in front of the gfxmenu statement thereby disabling it and obtain a text menu instead. In a text menu you deal with Grub directly and can overcome any problem by pressing the "c" key to drop into a Grub prompt.

There is no installed operating system in the world that you cannot boot up with a Grub prompt! I have tried for years and couldn't find one.

You can ask Grub to tell you the geometry of disk (hd0) and (hd1) by command
Code:
geometry (hd0)
geometry (hd1)
from which you can see the partitions and able to tell which is which exactly the way Grub sees it.

You can ask Grub to display your menu.lst, say it is in (hd0,0) by command
Code:
root (hd0,0)
cat /boot/grub/menu.lst
You can ask Grub to fire the menu.lst up in (hd0) by command
Code:
root (hd0)
configfile /boot/grub/menu.lst
You can edit the lines while booting with the "e" (for edit).

You can display any menu.lst and follow the commands to boot any system manually in a Grub prompt.

You can ask Grub to reboot or turn off the PC.

You will not be able to find a program that works faster than a Grub prompt.

So why go through a middleman like gfxmenu. Talk to Grub directly and let it solve all your booting problems.
 
Old 05-10-2008, 05:27 AM   #15
Tomermory
Member
 
Registered: Mar 2007
Location: Amiens, France
Distribution: Debian Etch,
Posts: 181

Original Poster
Rep: Reputation: 30
This is very interesting! I had no idea that you could do so many things with Grub. Do you have any links for a good Grub tutorial?
 
  


Reply

Tags
grub, mbr, move



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
quick question about grub bootloader & installing another distro Ay-Karamba! Linux - Newbie 12 10-14-2005 09:00 AM
Installing grub without a distro squimmy Linux - Newbie 8 07-20-2005 01:28 PM
GRUB or LILO won't boot linux!!! for ANY distro stelmate Linux - Hardware 12 05-27-2005 06:42 PM
appending grub - add other linux distro machiner Fedora 2 10-10-2004 02:38 PM
apart from grub fedora 2 is the best linux distro unixmad Fedora 1 08-29-2004 05:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:38 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