[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: initrd -- what exactly is it?



    "Matt" == Matt Price <matt.price@utoronto.ca> writes:

    Matt> hi there, can someone help me figure out what exactly initrd
    Matt> is, and why kernels use it?  I have looked through the docs,
    Matt> and I understand that it's thefile used for an initial
    Matt> ramdisk in some cases, but I don't understand why it would
    Matt> be used in some cases and not in others.  So for inst ance,
    Matt> the demudi kernel I just installed seems to demand the use
    Matt> of initrd, and I take it GRUB needs an anitrd argument to
    Matt> load the kernel.  But why don't my own self-compiled kernels
    Matt> require an initrd argument at boot (nor have an initrd file
    Matt> anywhere in /boot, as far as I can tell)?

I'm not expert on this, but here goes anyway: the initrd image is,
like you point out, a ramdisk image that common Linux bootloaders
(lilo, grub, ....) can load off a wide variety of file systems.

There is no real need to use initrd for personal use. If you know
exactly what you need in your kernel, just build it in. (well,
personally, I never build a kernel unless my hardware requires it, the
pre-packaged Debian kernels are wonderful bits of art :-)

Initrd gets to be very useful when you try to build a kernel that will
be used in a wide variety of environments. You don't want to build
everything into the kernel, but at the same time you are not sure what
might be required to boot a system up and find the rest of the system.

In that case you build a small kernel with what you know everyone will
absolutely need. Then you throw a lot of stuff that will satisfy a
large variety of systems into the intird image. The initrd ram disk is
used to bootstrap the kernel: basically you boot the kernel, mout the
initrd image, which pokes around and loads modules it figures that
specific system needs to find the rest of the hardware (e.g. it needs
ext3 or rieserfs file system support for the root partition or some
such thing), then mounts the root file system and goes on with the
usual initialization.

The advantage is of this approach is, for example, that if you don't
use ext3 you will not find ext3 in your memory. But if you use ext3
you can still boot the system even though ext3 is not built into the
kernel (because it is in the initrd image).

You can use 'mount -t cramfs -o loop /mnt intrd.img.file.path' to look
into an initrd image. You will find it quite instructive I'm sure.

Cheers!
Shyamal



Reply to: