Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
While booting, the Kernel has to mount the root file system, and the root file system can be accessed by modules. But these modules are present inside the Root file system itself. Now the question here is, how can the root file system be mounted when the modules, that are responsible for mounting this root file system, are within the root file system itself. This is something like 'How do you get a chicken when you do not have an egg? And how do you get an egg when you do not have a chicken?' Hence, it is called the Chicken-Egg problem.
So, we use 'initrd' image file. This is an image file that consists of necessary modules to mount the root file system, in read-only module. Once the RFS is mounted, then the modules are invoked and then the RFS is again mounted in RW mode.
Can somebody delve deep into booting . I know that
first 512 bytes of hard disk form MBR which points to partition to boot from . From that address bootloader is loaded . What next ?
Can somebody delve deep into booting . I know that
first 512 bytes of hard disk form MBR which points to partition to boot from . From that address bootloader is loaded . What next ?
You've been registered here for FIVE YEARS...by now, you should know not to hijack someone elses thread, or re-open old ones. And if you put "how does linux boot" into Google, the VERY FIRST HIT is: http://www.ibm.com/developerworks/library/l-linuxboot/
While booting, the Kernel has to mount the root file system, and the root file system can be accessed by modules. But these modules are present inside the Root file system itself. Now the question here is, how can the root file system be mounted when the modules, that are responsible for mounting this root file system, are within the root file system itself. This is something like 'How do you get a chicken when you do not have an egg? And how do you get an egg when you do not have a chicken?' Hence, it is called the Chicken-Egg problem.
So, we use 'initrd' image file. This is an image file that consists of necessary modules to mount the root file system, in read-only module. Once the RFS is mounted, then the modules are invoked and then the RFS is again mounted in RW mode.
Let me know, anybody, if I am wrong.
I would say, incomplete. The problem is that you move the location of the question to the initrd...
When the kernel is loaded, it usually has two mandatory drivers. ramfs for a memory resident filesystem, and a console.
The way thing go, is the when the kernel is loaded (by grub, lilo...) it is also loaded with a compressed cpio archive of a mini-root filesystem (the initrd). The kernel level init process mounts the ramfs, and then copies (memory to filesystem) the initrd passing it through a cpio (also built in) to create a memory resident filesystem, after which the initrd is deallocated. This memory resident filesystem is used as root, so the kernel level init process executes a startup shell script on that filesystem. The script is used to load modules as needed (it has a udev service on board that builds another memory resident filesystem, devfs, than ends up mounted as /dev ).
Once the device scan is finished, the script goes through all partitions looking for the partition designated on the kernel command line (the "root=" parameter). It mounts the identified partition on /mnt. Once this is completed, the script exits...
Now the kernel init uses the /mnt mounted disk based root and invokes a little used system call "piviot_root" - which exchanges the /mnt data stucture describing the mount, and the mini-root mount. After this is completed, the mini-root (now located on /mnt) is dismounted (memory reclaimed) and the kernel init execs the /usr/sbin/init executable from disk.
After that, the rest of the system is brought up- /dev is mounted, other disk mounts, and then any services.
Note: it IS possible to bypass this. But to do so requires the kernel to have the driver for the disk built in and the root filesystem type builtin, and to have the root device specified by driver name. I'm not sure that even the partition UUIDs and labels are yet known.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.