Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Installation > grub

Forgot Password?
 Installation   Need help or have questions about installing Linux, including dual booting with other distros or Windows? put them here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 04-12-2003   #1 (permalink)
Linux Engineer
 
Join Date: Nov 2002
Location: Queens, NY
Posts: 1,319
Send a message via AIM to bpark
grub

Is anyone good with grub? I'm trying to find out somethings about it and the grub document isn't really satisfying my curiosity.
Code:
title Debian GNU/Linux
root (hd0,1)
kernel /vmlinuz root=/dev/hda4
I have 4 partitions on my primary IDE hard drive. Here are the partition labels
Code:
Format  Partition  Name(using grub scheme)
NTFS   (hd0,0)  Windows
ext3    (hd0,1)  boot
??       (hd0,2)  swap
ext3    (hd0,3)  Linux
What I'd like to understand is the function of my boot partition. I know the boot partition contains the grub directory along with the appropriate images and vmlinuz. My question is when I run 'root (hd0,1)', this will load the boot partition into grub. What is the purpose of this?
Then when I run the next line 'kernel /vmlinuz root=/dev/hda4', does grub use vmlinuz in my boot partition or the vmlinuz in my root linux partition(hd0,3)? Also, when I edit menu.lst which is in (hd0,3), how does the MBR read this info everytime it's changed?
__________________
The best things in life are free.
bpark is offline  



Reply With Quote
Old 04-12-2003   #2 (permalink)
Linux Enthusiast
 
Join Date: Jun 2002
Location: San Antonio
Posts: 622
Send a message via AIM to wassy121
see, grub is a really smart bootloader program. Let's take these questions in order:
Quote:
when I run 'root (hd0,1)', this will load the boot partition into grub. What is the purpose of this?
this is to tell grub where the kernel images are located for use on the next line (you could have multiple partitions with multiple kernels on each partition, so grub wants to know).

Quote:
Then when I run the next line 'kernel /vmlinuz root=/dev/hda4', does grub use vmlinuz in my boot partition or the vmlinuz in my root linux partition(hd0,3)?
the "root=/dev/hda4" isn't even interpreted by grub. grub sees that as a kernel argument, so it ignores it and uses the root specified by the "root (hd0,1)" command earlier. Then the kernel starts loading, sees the "root=/dev/hda4" command line parameter, converts it into numbers it knows (08:04 I think), and goes on like grub didn't even exist.
Quote:
when I edit menu.lst which is in (hd0,3), how does the MBR read this info everytime it's changed?
good question, I think it reads the menu.lst file every time it loads from the MBR. You can source dive to find the answer if you want, I am not particularly sure either way.
__________________
I respectfully decline the invitation to join your delusion.
wassy121 is offline   Reply With Quote
Old 04-12-2003   #3 (permalink)
Linux Engineer
 
Join Date: Nov 2002
Location: Queens, NY
Posts: 1,319
Send a message via AIM to bpark
Quote:
this is to tell grub where the kernel images are located for use on the next line (you could have multiple partitions with multiple kernels on each partition, so grub wants to know).
So is vmlinuz in my boot partition(hd0,1) is the actual kernel image that is being loaded?

Quote:
the "root=/dev/hda4" isn't even interpreted by grub. grub sees that as a kernel argument, so it ignores it and uses the root specified by the "root (hd0,1)" command earlier. Then the kernel starts loading, sees the "root=/dev/hda4" command line parameter, converts it into numbers it knows (08:04 I think), and goes on like grub didn't even exist.
Again, the kernel image is loaded from (hd0,1). The argument isn't seen by grub but we need it since /dev/hda4 is the LINUX root. Basically, once grub loads the kernel image, it's setting it's next root to be the LINUX root. This much makes sense. If I didn't have a boot partition, would it be possible to do this
Code:
# choice one
title Linux
root (hd0,3)
kernel /vmlinuz

#choice two
title Linux
kernel (hd0,3)/vmlnuz root=/dev/hda4
What is the benefit of having a boot partition?
My next question deals with installing a new kernel. First, do I need to place the image on the boot partition(hd0,1)? How do I get initrd to work in grub?
__________________
The best things in life are free.
bpark is offline   Reply With Quote
Old 04-12-2003   #4 (permalink)
Linux Enthusiast
 
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 556
Send a message via ICQ to yowwww
this may or may not help, but for your reference purposes:

http://www.geocities.com/cyberkabila/main/grub.htm
yowwww is offline   Reply With Quote
Old 04-12-2003   #5 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
Quote:
Originally Posted by bpark
Basically, once grub loads the kernel image, it's setting it's next root to be the LINUX root.
It's _next_ root? I'm afraid you might have misunderstood.
First there is GRUB's "root" partition. That term doesn't really describe its purpose. It should actually be called default partition, meaning that it's the partition used if no partition is specified in a filename. That also answers your other question; (hd0,3)/vmlinuz would be the same as seperating it into two lines, one root line and one kernel line.
Then there is Linux's root partition, on which the root directory is mapped to the VFS' root directory. That is what the kernel gets from the root=/dev/hda4. Really, wassy, you should have known that hda4 is 03:04, not 08:04. =) You could just as well specify root=03:04. In fact, I usually do that. GRUB does "see" that argument, but it doesn't parse it; it just passes it on to the kernel when it boots it. When the kernel boots, and before it has mounted its root partition, there is no concept of a root partition.
There is really one other purpose of GRUB's root partition. When it's specified, GRUB doesn't need to detect the filesystem type every time you specify a file name, providing that you actually run several commands that use file names, that is.
Note, however, that you can't do this:
Code:
root (hd0,3)
kernel /vmlinuz
That's because, like I said, GRUB's root partition is in no way related to Linux's root partition. So you still need to specify root=/dev/hda4 (or root=03:04).
OK, enough on that.

Generally, there is no longer a benefit of having a boot partition. A long, long time ago, before the time of LBA, you couldn't access more than like 100 MBs or so into a hard drive from the BIOS. Therefore, the boot partition needed to be the first partition on the drive, so that the kernel image could always be accessed. Nowadays with LBA, however, you don't need it unless you have a broken BIOS.

Note also, that if you have no boot partition, you can't do "kernel /vmlinux", unless you actually have the kernel image in your root directory. Normally, however, you still have the kernel image in /boot, even though it's on the same partition. Therefore, you'd need to do "kernel /boot/vmlinuz" in that case.

About menu.lst, or grub.conf as it links to, I believe GRUB, when it starts, searches all partitions it can find for the files /grub.conf, /boot/grub.conf and /grub/grub.conf.

As for initrd, just use the initrd command. Specify the file name as its argument, and that's it.

For more info, see the GRUB texinfo documentation. It's really thorough.
Dolda2000 is offline   Reply With Quote
Old 04-13-2003   #6 (permalink)
Linux Engineer
 
Join Date: Nov 2002
Location: Queens, NY
Posts: 1,319
Send a message via AIM to bpark
dolda to the rescue

Quote:
That term doesn't really describe its purpose. It should actually be called default partition, meaning that it's the partition used if no partition is specified in a filename.
What happens if I don't use the root command to mount a partition to grub. What partition would be used in that situation?

Quote:
About menu.lst, or grub.conf as it links to, I believe GRUB, when it starts, searches all partitions it can find for the files /grub.conf, /boot/grub.conf and /grub/grub.conf.
I have menu.lst in my boot partition and my linux partition. The linux partition file is always modified. Since the menu.lst in the boot partition has never been modified, I'm assuming that GRUB is smart enough to know which one to use. Perhaps it looks at the time stamp to see which one is more recent?
__________________
The best things in life are free.
bpark is offline   Reply With Quote
Old 04-13-2003   #7 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
Quote:
Originally Posted by bpark
What happens if I don't use the root command to mount a partition to grub. What partition would be used in that situation?
GRUB would probably issue an error if you try to use a file without having either explicitly specified the partition in the file name or "mounted" a root partition, as it doesn't know which partition to look on.
Quote:
Originally Posted by bpark
I have menu.lst in my boot partition and my linux partition.
Are you sure that one isn't just symlinked to the other?
Dolda2000 is offline   Reply With Quote
Old 04-13-2003   #8 (permalink)
Linux Engineer
 
Join Date: Nov 2002
Location: Queens, NY
Posts: 1,319
Send a message via AIM to bpark
Dolda,

I am positive that they aren't symlinks. One resides in (hd0,1) and the other resides in (hd0,4). Both files are different.
__________________
The best things in life are free.
bpark is offline   Reply With Quote
Old 04-13-2003   #9 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
There you see. That's more than I knew. I guess I'll almost have to check how GRUB finds its config file.
Dolda2000 is offline   Reply With Quote
Old 04-14-2003   #10 (permalink)
Linux Engineer
 
Join Date: Nov 2002
Location: Queens, NY
Posts: 1,319
Send a message via AIM to bpark
i'll be damned

Well I'll be damned. This is the first time that Dolda wasn't able to answer a question of mine. I'll do some more reading on it and see if I can find something on this too.
__________________
The best things in life are free.
bpark is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
A Newbie's Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it.
subscribe
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 12:49 AM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1