Find the answer to your Linux question:
Results 1 to 4 of 4
Hello All, I have a question on how the kernel knows the root directory. For example, in grub menu.lst file we specify root=/dev/hda1. This tells the kernel to find mount ...
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    9

    How does kernel know the root directory?

    Hello All,
    I have a question on how the kernel knows the root directory. For example, in grub menu.lst file we specify root=/dev/hda1. This tells the kernel to find mount the root directory from /dev/hda1. But to read /dev/had1 it should first know where is '/' . I couldn't understand how this is being done. Could anybody please explain me?? Thank you....

    Thanks,
    Bala

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Hi and Welcome !
    For example, in grub menu.lst file we specify root=/dev/hda1. This tells the kernel to find mount the root directory from /dev/hda1.
    It doesn't tell the kernel to find anything. It specifically inform kernel that /dev/hda1 is root filesystem. For mount points of other partitions/systems, if any, /etc/fstab file is default conf.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I can't prove this, but because /dev is actually populated by the kernel (these are not actual files, but simply interfaces into the kernel), I would not be surprised if the kernel understands /dev/hda1 even before a root is chosen.
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    Just Joined! sixdrift's Avatar
    Join Date
    Jan 2007
    Location
    In and around and about Cary, NC
    Posts
    44
    When you install grub, it stores a device.map file that contains a mapping of partitions to /dev locations. For example, it could contain something like this:

    (hd0) /dev/hda
    (hd1) /dev/sda

    So the file system rooted on hd0 is at /dev/hda and the file system rooted on hd1 is /dev/sda in this example. Then references to /dev/hda1 are mapped to the hd0 partition.

    So its not a chicken and egg thing after all. The /dev labels are used in the device.map file to find the partition, but when you boot the kernel, it builds up its /dev directory and ensures it has the proper entries which ultimately will contain a /dev/hda1 but that is not known at grub boot time.

    At least I think this is how it works. I could be wrong.

Posting Permissions

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