LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 06-08-2006, 05:32 PM   #1
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
How does GRUB know what drive to go to?


I have a vague memory of reading about this, but I can't find it.

When GRUB is installed to--eg--the MBR, how is it configured to look at the correct disk/partition for its config file, etc.? By implication, it sets some code based on the location from where it was installed.

As just one example, if you were trying to rescue an existing install, I assume you could not install GRUB from a live CD and expect it to work with the existing setup.
 
Old 06-08-2006, 06:16 PM   #2
beagle2
Member
 
Registered: Aug 2004
Location: Aberdeen Scotland
Distribution: elive,sidux,xp,pclinuxos super gamer, mandriva 2007
Posts: 417

Rep: Reputation: 30
Heres the long answer http://www.gnu.org/software/grub/manual/grub.html , short answer is if you were to re-install grub in the same position as the original ie grub-install /dev/hda and the /boot/grub/menu.lst still exists, grub will boot up again as before.
 
Old 06-08-2006, 06:29 PM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
It knows the drives from the /boot/grub/device.map .

If I wanted to restore my Fedora grub, I would run the command:
grub

Then, I would tell grub where to look for the grub.conf ( which is located on the second drive, second partition ) with the command: root (hd1,1)

Then, I would tell grub to use the mbr of the first drive with the command: setup (hd0)

type: quit to exit the grub utility.


If I wanted to use my Suse grub.conf ( which is located on /dev/sda6 ) I would use the command: root (hd0,5)

If I wanted to use the Mandriva grub.conf ( which is located on /dev/sda2 ) I would use the command root (hd0,1)
 
Old 06-08-2006, 06:58 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Original Poster
Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Makes perfect sense...
Ergo, if I dump out the GRUB code on the mbr, there will be some bytes that are unique to the installation. Anyone know the details of where this is found?
 
Old 06-09-2006, 12:00 AM   #5
DeusExLinux
Member
 
Registered: May 2004
Location: Tampa, Fl
Distribution: Arch
Posts: 648

Rep: Reputation: 30
There isn't really anything unique in the mbr.

I've installed grub from one distro, then used the same instillation of grub, and physically copied a new distro the the root partition (in this case it was (hd0,3) and rewrote the /boot/grub/menu.lst and it worked fine.

It's really the location of the menu.lst file that's important, and grub just needs to know where it is, which, as stated above, can be fixed with a simple command.
 
Old 06-09-2006, 08:04 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Original Poster
Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
It's really the location of the menu.lst file that's important, and grub just needs to know where it is, which, as stated above, can be fixed with a simple command.
I know this is a bit esoteric, but the question is HOW grub knows where menu.lst is. there's no config file with that info---ergo it must be actually embedded in the mbr code.
 
Old 06-09-2006, 08:23 AM   #7
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
Originally Posted by pixellany
I know this is a bit esoteric, but the question is HOW grub knows where menu.lst is. there's no config file with that info---ergo it must be actually embedded in the mbr code.
It is not in MBR code, it's in stage 1.5, which is can be located in several places outside of filesystems.

Edit: Stage1.5 location is recorded into MBR code, usually stage1.5 is located in empty area right after MBR.

Last edited by Emerson; 06-09-2006 at 08:32 AM.
 
Old 06-09-2006, 09:25 PM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Original Poster
Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
OK---so how does ***stage 1.5*** know where to go for menu.lst?
 
Old 06-10-2006, 04:05 AM   #9
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Stage1.5 can read the filesystem it is made for and stage2 from it. This means you can move your stage2 around and stage1.5 will find it as long as the path remains unchanged. You can guess from here. Stage2 can read the filesystem too and reads menu.lst.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing grub to external USB hard drive for later use as internal hard drive dhave Linux From Scratch 2 12-10-2005 08:48 AM
Grub Won't Boot Drive in New PC ajw70 Red Hat 10 09-11-2005 05:24 AM
Installed GRUB on 3rd hard drive, how do I boot 1st drive? jesusphreak Linux - Newbie 4 04-06-2005 09:34 AM
Grub to access new hard drive and old multi os hard drive ? gedi1 Linux - Hardware 0 06-03-2004 12:01 PM
drive with grub died, what now? ngrover Linux - Newbie 2 11-02-2003 03:48 PM

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

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