LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-12-2018, 09:28 PM   #1
joemon83
Member
 
Registered: Jan 2009
Posts: 71

Rep: Reputation: 11
mounting by grub and initramfs


Hi,
This might be basic question, but just wanted to clarify this.
If grub stage 2 can mount the root filesystem in read only mode and load kernel and initramfs from it, why do we need initramfs to create something called temporary root filesystem in read only mode. Is it bcoz grub can't mount root filesystem to a mount point ?
 
Old 05-13-2018, 06:21 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
I haven't looked at the code, but there is no requirement for a bootloader to "mount" anything - it simply needs to know how to find the kernel and (if present) the initrd and read them off disk. This used to be hard-coded - hence the problems for legacy grub when ext[34] extended the inode size. New filesystems (btrfs) also bring new inconsistencies.
It looks like grub2 gets around this with modules that can be (re-)written to accommodate changes.

The initrd primarily exists to ensure the necessary support for the kenel to mount the root are present - notably disk controller and such. All that has to be built into the initrd itself. Distros usually add other functionality - say PXE booting.
The initrd is entirely optional if the necessary support is buit in at kernel compile.
 
Old 05-13-2018, 11:47 PM   #3
joemon83
Member
 
Registered: Jan 2009
Posts: 71

Original Poster
Rep: Reputation: 11
THanks for the reply.
I was talking about not so legacy Linux like rhel 5 and 6.
grub accesses kernel/initrd using (hd0,0)/boot/vmlinuz...and /boot/initrd.
this doesn't look like hardcoding, but rather reading from filesystem or else it won't even understand the directory structure.
 
Old 05-14-2018, 01:37 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,993

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
Simple.

https://linuxjourney.com/lesson/boot-process-kernel

More detailed.

https://www.ibm.com/developerworks/l...trd/index.html
 
Old 05-14-2018, 02:34 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
Well, those deal with how the kernel and initrd are built and how they operate once they are loaded. In order to get those files loaded, GRUB does have internal knowledge of filesystem structure and can parse that structure without, technically**, mounting it. It is much the same as the way fsck, debugfs, and the like parse the internal structure of an unmounted filesystem.

In the case of GRUB legacy, the stage 1.5 bootloader is built with knowledge of one filesystem, that being the filesystem that contains /boot.

GRUB2 starts out in a similar manner, but once the bootloader has gained access to the /boot/grub2 directory there are many loadable modules available to handle various filesystems as well as video drivers, networking, encryption, USB serial devices, etc. All filesystems are handled by parsing their structure and not by mounting them. Mounting would imply that there is some mount point directory on which to mount them, and there is not (yet) a root filesystem on which to do that.
** Note that the word "mount" here is being used in the specific sense of attaching a filesystem to a point on the overall directory tree and not in the more general sense of "make available for processing," such as mounting a device that contains a tar archive.

Last edited by rknichols; 05-14-2018 at 07:52 PM. Reason: grammar
 
1 members found this post helpful.
Old 05-14-2018, 07:34 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,993

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
Opps, grub legacy.
 
Old 05-17-2018, 05:44 AM   #7
joemon83
Member
 
Registered: Jan 2009
Posts: 71

Original Poster
Rep: Reputation: 11
Thanks rknichols.
That clears my doubt..
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Mounting root filesystem in custom initramfs : No such file or directory anon_16 Linux From Scratch 3 03-06-2015 04:03 AM
Can't boot from CD. Grub Rescue> - Initramfs - Only Linux commands will save me. Wet Willie Linux - Newbie 22 05-13-2013 05:10 PM
Grub and initramfs in squeeze piccir Linux - Kernel 5 06-07-2010 04:47 AM
Grub and Mounting problem jestinjoy Linux - Newbie 5 09-13-2008 09:45 AM
Mounting issues in Grub kokoba Linux - Laptop and Netbook 9 03-11-2006 10:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:01 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