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.
Hi Forum,
I spent some time trying to understand the boot process and I have a doubt.
As per my knowledge,stage1 grub points to stage2 which is in /boot/grub/stage2. My question is how come stage1 triggers stage2 when no file-system is mounted. I mean how does it invoke stage2 located at /etc/grub/stage2 when the root file-system is not yet mounted. Since first ever mounting happens during initrd and kernel loading??
Can some please shed some light on this??
It could do it the way Lilo does: Finding the exact location off the kernel on the disk at install time, the just loading it from there. This make Lilo file-system agnostic.
But in case of Grub you are right, it has its own drivers.
Grub has its own built in file system drivers. Essentially it is a simple operating system
In fact, how else could it load the kernel?
Well, its still not clear to me, btw I never read this anywhere on the internet that grub has its own set of drivers. But I want to understand what happens as soon as stage 1 comes in to play till the kernel is loaded. Can anyone outline in detail what happens during that period???
IIRC smeezekitty could probably expound quite well on this. this wikipedia article is pretty good for a high level view - the IBM developerworks site used to have a decent one as well. Exercise your favourite search engine.
As alluded above, different loaders handle things differently - even grub versus grub2. The latter makes it (more) obvious it is loading filesystem support.
Well, its still not clear to me, btw I never read this anywhere on the internet that grub has its own set of drivers. But I want to understand what happens as soon as stage 1 comes in to play till the kernel is loaded. Can anyone outline in detail what happens during that period???
It could do it the way Lilo does: Finding the exact location off the kernel on the disk at install time, the just loading it from there. This make Lilo file-system agnostic.
... which is also why making innocent modifications to the disk without re-running the LILO installer can result in an unbootable system!
... which is also why making innocent modifications to the disk without re-running the LILO installer can result in an unbootable system!
Correct. Back in the days of Grub 1 that was one of the main arguments against Lilo: You have to re-run it after making changes. Funnily that is a behavior that was re-introduced with Grub 2 and its system using scripts to generate a config file.
Correct. Back in the days of Grub 1 that was one of the main arguments against Lilo: You have to re-run it after making changes. Funnily that is a behavior that was re-introduced with Grub 2 and its system using scripts to generate a config file.
Uh huh. Yeah. New and improved ... Oh, well. (And I'm not even "dissing" LILO, either, btw. It's all good...)
Last edited by sundialsvcs; 10-31-2013 at 06:33 PM.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339
Rep:
Quote:
Originally Posted by amit.kanade1983
Well, its still not clear to me, btw I never read this anywhere on the internet that grub has its own set of drivers. But I want to understand what happens as soon as stage 1 comes in to play till the kernel is loaded. Can anyone outline in detail what happens during that period???
I don't know the exact process because I didn't research it in depth.
But basically the early portion of GRUB exists in the master boot record which is loaded by the BIOS.
This contains just enough code to load in the stage one code.
The stage one code most likely contains basic file system drivers for common file systems like EXT2/3/4 and FAT
It will look in the configured directory for stage2 in the file system tables, it then loads it from the disk sectors that are pointed to by that entry.
It then jumps to the loaded code which finds the kernel to be loaded in the file system table and loads it from the disk sectors listed.
If necessary it will also load a RAMDISK for the kernel to use.
Finally it jumps to the entry point in the kernel and off it goes.
I didn't explain as good as I could have but basically it reads the filesystem just like any operating system does.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.