Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
here the additional “root=/dev/hda” is in order to instruct the kernel which device has to be mounted as root file system (/)
Now my (chicken - egg) doubt is: how the kernel can find out which disk partition the device /dev/hda represents if the root filesystem is not available yet (because not mounted yet)?
If the device and controller support is compiled into the kernel, the kernel can find the device it needs - else, as stated, the initrd has to incorporate the support.
BTW is would be unusual to have a device specified as root=...
Not unknown, but not normal. The kernel doesn't need the root mounted - everybody else does.
If the device and controller support is compiled into the kernel, the kernel can find the device it needs - else, as stated, the initrd has to incorporate the support.
The kernel doesn't need the root mounted - everybody else does.
ok, thus basically kernel just know that the string '/dev/hda' refers to the first disk of IDE controller and so on...(e.g. /dev/hdb the second IDE controller's attached disk....) and it is not conceived as a path starting from / (because as you pointed out kernel doesn't need root filsystem mounted).
LILO performs raw mapping, so it loads the kernel by mapping it's location on the disk (this is done when you run lilo and it parses the config file and writes itself to the mbr).
Grub can read some filesystems (particularly ext2/3/4) and can load it's configs and kernels directly.
You usually do need to specify the root filesystem if you've configured to load an initrd/initramfs.
Grub probably has built-in support for the filesystem you are using. It knows how to identify the filesystem and to read the files without relying on the support of an operating system that, of course, does not exist yet.
Notice, however, that it has its own device-numbering system, counting from zero. You must use a form of device reference that is understood by GRUB.
Grub comes-and-goes before the "initrd" step is reached.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
Quote:
Originally Posted by cianfa72
ok, thus basically kernel just know that the string '/dev/hda' refers to the first disk of IDE controller and so on...(e.g. /dev/hdb the second IDE controller's attached disk....) and it is not conceived as a path starting from / (because as you pointed out kernel doesn't need root filsystem mounted).
Does it make sense ?
That's how I always read it -- hence the issues when another HDD is installed at boot and the kernel finds it first.
Grub probably has built-in support for the filesystem you are using. It knows how to identify the filesystem and to read the files without relying on the support of an operating system that, of course, does not exist yet.
Notice, however, that it has its own device-numbering system, counting from zero. You must use a form of device reference that is understood by GRUB.
As far as can I understand, here you're talking about the boot loader (GRUB in this case) and how it can locate the kernel image + initramfs (eventually) from the boot partition (basically the disk partition with a filesystem on it storing, among other files, the kernel image + initramfs).
My original question was instead how the kernel code itself (loaded in RAM by GRUB for instance) can "interpretate" the 'root=/dev/hda' option passed to it in order to locate and mount as / the filesystem in the disk partition that will become "the root partition".
I'm puzzled by all the references to /dev/hda. That's the designation for a drive, not a partition. The root partition should have the name /dev/hda[1..4] (or more likely these days /dev/sda[1..4]).
As far as I know, the kernel assigns the disk device name when it detects the disk. It then goes to the partition table of the disk and finds out where that particular numbered partition begins and ends. It mounts that partition on /.
If there's an initrd, it gets loaded onto a ramdisk and that becomes the root device until it calls pivotroot to switch to the real thing.
I'm puzzled by all the references to /dev/hda. That's the designation for a drive, not a partition. The root partition should have the name /dev/hda[1..4] (or more likely these days /dev/sda[1..4]).
As far as I know, the kernel assigns the disk device name when it detects the disk. It then goes to the partition table of the disk and finds out where that particular numbered partition begins and ends. It mounts that partition on /.
Sure, maybe it is just a typo: basically you are saying the kernel just "knows" for instance the string '/dev/hda1' (passed as 'root=' boot parameter by GRUB to it) refers to the first partition of the disk it has detected and named as /dev/hda1'. Then, if there is not initrd, that partition will be mounted as /.
Now, if that is right, next point is: when the content of fstab file is read and the filesystems referred there are mounted as specified ?
You need to know that disk nomenclature has changed over the past 2-3 years. Under the old system, the kernel named IDE disks according to their location: the master drive on the first controller was hda and the slave was hdb. For the second controller the names were hdc and hdd. SCSI drives were sda, etc, named in the order in which they were detected.
No modern kernel does this. The modern disk driver handles IDE and SCSI disks identically and calls them all sd*. To avoid random device name changes during boot, the udev daemon enforces fixed names and informs the kernel about them.
Mounting filesystems other than root is done by one of the init scripts. It's usually called something like mountfs.
Also: the only thing that Grub does is to provide a string to the kernel in an agreed-upon location before it forever hands-over the car keys. Grub does not know, nor does it care, what the string might mean to Linux. Interpretation of the string, including deciding just what /dev/foobar means to the kernel, is entirely up to the kernel ... and Grub is long gone by then. It's entirely up to you to provide the "correct" string. Grub knows nothing about them except, "the human told me to give you this."
Grub uses its own device-id scheme, counting from zero, for its own purposes. It is able to determine which device the computer was booted from, and it is capable of reading several common file systems so it is able to find and read its configuration files. (It's really a very "smart" program by now.) Grub reads these files and must correctly interpret them. Linux knows nothing about them except that they are there.
Last edited by sundialsvcs; 03-22-2017 at 07:57 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.