Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319

    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.

  2. #2
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    see, grub is a really smart bootloader program. Let's take these questions in order:
    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).

    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.
    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.

  3. #3
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    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?

    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.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Enthusiast
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    556
    this may or may not help, but for your reference purposes:

    http://www.geocities.com/cyberkabila/main/grub.htm

  6. #5
    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.

  7. #6
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319

    dolda to the rescue

    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?

    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.

  8. #7
    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?

  9. #8
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    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.

  10. #9
    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.

  11. #10
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319

    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.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •