Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
What is /dev/ram0?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
steveglimache
n00b
n00b


Joined: 21 Dec 2004
Posts: 12

PostPosted: Wed Dec 22, 2004 5:52 pm    Post subject: What is /dev/ram0? Reply with quote

Greetings,
I successfully finished my first Gentoo install ever. Everything during the installation seemed to have gone smoothly (except for figuring out the zillion options when configuring the kernel using genkernel --menuconfig all, but that is a subject for another thread...). At the end of the kernel build, there was a message telling me that the following boot options are required:
Code:
root=/dev/ram0 real_root=/dev/hda2 init=/linuxrc ramdisk_size=8192
So when I arrived to installing the bootloader (LILO in my case), I put the following line:
Code:
root=/dev/ram0
Just as was "required" by my newly built kernel and which incidently happens to match the gentoo-x86-quickinstall guide.

But when I rebooted the system, it booted partially, refusing to go on, since needed "sectors" where beyond limit (4096 or so).

I immediately connected this with the fact that when I configured the kernel I asked for a small ramdisk size of 8192KB. So I quickly changed the root LILO line to:
Code:
root=/dev/hda2
(where my root partition is) and bingo - the system boots properly and fully.

I am very happy now :D but now I need to understand what was that "ramdisk" option in the kernel configuration (I told you that reading the explanation of each and every little option there was mind boggling.... ). I naively thought that all what I was doing was enabling an option to be able to allocate and mount a ram drive for some esoteric need in the future.

I didn't know that the ramdisk option is solely for storing the root filesystem (/). Or is it?

Could someone enlighten me please regarding this particular option? (a pointer to some relevant documentation would suffice).

Also, why does the kernel build process end with a message that says that "root=/dev/ram0" is required when this is clearly not the case? (perhaps optional, but required???)

Thanks,
Steve
Back to top
View user's profile Send private message
Moloch
Apprentice
Apprentice


Joined: 17 Mar 2003
Posts: 293
Location: Albuquerque, NM, US

PostPosted: Wed Dec 22, 2004 6:02 pm    Post subject: Reply with quote

Fully reread: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2

What is is saying is:
First option is if you configured your kernel by hand "make menuconfig". You are simply telling it your root[ / ] is on /dev/hda3. Most people don't enable the initrd stuff when they do it by hand.

Second configuration is if you compiled your kernel with genkernel. Which is an automatic script. It adds some more complex options (which is why a lot of us don't like it). There options require a "mini virtual root"(initrd) before loading the real root. Note the option "real_root=/dev/hda3". /dev/ram0 is simply a ramdisk that the initrd is loaded into.
_________________
Understanding is a three-edged sword: your side, their side, and the truth. --Kosh
1010011010
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 55180
Location: 56N 3W

PostPosted: Wed Dec 22, 2004 6:33 pm    Post subject: Reply with quote

steveglimache,

/dev/ram0 is the mountpoint for mouting an initrd file if you have one.
Getting a computer started (booted) is a problem whatever OS you use. On linux you get to see it. Simply stated, its the need to be able to load the operating system from disc without an operating system in memory to read the disc.
The term Bootstrap (shortened to boot over the years) comes from Greek mythology, from the God who pulled himself up to heaven by tugging on his own bootstraps.
Clearly this infinite recursion needs to be broken.
It starts in the BIOS. The BIOS loads the very first block off the boot disk (the Master Boot Record) into memory and jumps to the first instruction. Thats the BIOS done.
The MBR loads some more sectors from the disk. For Grub its about 23, using calls to the BIOS. These sectors are loacated after the MBR and before the start of the first partition. This is Grubs, stage 1.5.
Stage 1.5 knows enough to read the /boot dorectory structure to find and load stage 2, which loads the kernel and initrd, if one was specified. (/boot is not mounted for this)
The kernel is now in memory but not yet started and the problems are not over yet.

When grub passes control to the kernel, it initalises itself and mounts the root partition. There is a problem here if the modules needed to mount the root partition have been made as modules and are on disk because the kernel needs the modules to read the disk where the modules are.
One way out of this is to ensure that everything needed for booting is built in. Its always needed anyway. Another way is to have a fake root partition that holds everything needed to get started,
This is what an initrd (INITial Ram Drive) is.
The kernel knows how to read a ram drive, so the bootloader attaches it to /dev/ram0.
At startup the kernel mounts this ae the root filesystem, loads its modules to read the real root filesystem and off it goes.

The advantages of an initrd are that it allows a lean generic kernel to be made, that can be booted across a whole range of systems without leading to bloat because the initrd is unloaded when startup is complete.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
steveglimache
n00b
n00b


Joined: 21 Dec 2004
Posts: 12

PostPosted: Wed Dec 22, 2004 7:11 pm    Post subject: Reply with quote

Thank you NeddySeagoon and Moloch. You clearly helped me understand what inirtd is and how it relates to /dev/ram0.

I still don't understand however, why using the statement "root=/dev/ram0" (in my LILO) as instructed/recommended rendered the system unbootable, while changing it to "root=/dev/hda2" made it bootable.

If initrd is required (because I am using genkernel), why did its ommision help?

I now reall that I didn't put exactly the following line:
Code:
root=/dev/ram0 real_root=/dev/hda2 init=/linuxrc ramdisk_size=8192
I actually forgot to specify the ramdisk size and instead wrote in the LILO conf file:
Code:
root=/dev/ram0 real_root=/dev/hda2 init=/linuxrc
Could that be the reason?
Back to top
View user's profile Send private message
Moloch
Apprentice
Apprentice


Joined: 17 Mar 2003
Posts: 293
Location: Albuquerque, NM, US

PostPosted: Wed Dec 22, 2004 7:24 pm    Post subject: Reply with quote

That could be it. I don't use initrd. Not 100%. Actually I don't think using initrd is required by genkernel (I know before I said otherwise). It can make use of it. Like displaying a pretty startup screen similar to the LiveCD.
_________________
Understanding is a three-edged sword: your side, their side, and the truth. --Kosh
1010011010
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 55180
Location: 56N 3W

PostPosted: Wed Dec 22, 2004 7:37 pm    Post subject: Reply with quote

steveglimache,

Failing to specifiy the ramdisk size was almost certainly your problem. By default, the kerenl expects to deal with 4Mb ramdisks (compile time option). The initrd produced by genkerenl is bigger than this so you get errors when you try to read beyond 4Mb

You posted that you used genkerenl with menuconfig. If you changed the default genkerenel options, its quite possible to have it produce a kernel that dosen't need an initrd to get started.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
steveglimache
n00b
n00b


Joined: 21 Dec 2004
Posts: 12

PostPosted: Wed Dec 22, 2004 7:50 pm    Post subject: Reply with quote

NeddySeagoon wrote:
steveglimache,
You posted that you used genkerenl with menuconfig. If you changed the default genkerenel options, its quite possible to have it produce a kernel that dosen't need an initrd to get started.


OK, I think that explains it. I did change the default genkernel options (wanted to have as small as possible kernel for my particular system) which probably explains why it works without an initrd despite being a genkernel.

With this answer I feel confident enough now to go ahead and try again boot with initrd...

Thank you NeddySeagoon!
Steve
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum