LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 10-29-2013, 12:39 PM   #1
amit.kanade1983
Member
 
Registered: May 2012
Location: India
Distribution: CentOS,RedHat
Posts: 41

Rep: Reputation: 1
Linux boot process


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??
 
Old 10-29-2013, 01:19 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
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?
 
Old 10-29-2013, 01:24 PM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by smeezekitty View Post
In fact, how else could it load the kernel?
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.
 
Old 10-31-2013, 02:42 AM   #4
amit.kanade1983
Member
 
Registered: May 2012
Location: India
Distribution: CentOS,RedHat
Posts: 41

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by smeezekitty View Post
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???
 
Old 10-31-2013, 03:51 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
Old 10-31-2013, 07:01 AM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by amit.kanade1983 View Post
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???
http://moi.vonos.net/linux/Booting_L...86_with_Grub2/
 
Old 10-31-2013, 08:26 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Quote:
Originally Posted by TobiSGD View Post
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!
 
Old 10-31-2013, 10:19 AM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by sundialsvcs View Post
... 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.
 
Old 10-31-2013, 06:30 PM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Quote:
Originally Posted by TobiSGD View Post
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.
 
Old 10-31-2013, 10:46 PM   #10
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by amit.kanade1983 View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
The Linux Boot Process balachandar.giri Linux - Software 8 07-26-2010 02:18 AM
Boot process in Linux. tuhin_chatt Linux - Kernel 1 05-05-2010 04:36 AM
Linux boot up process Vs. Windows boot up process darkskull Linux - Software 7 12-30-2006 04:21 PM
Linux CD boot process amnesty_puppy Linux - General 1 11-29-2004 06:41 AM
A Question .. Linux boot process pyramid Linux - General 3 03-23-2001 06:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration