How to use initramfs for root filesystem?

839 views
Skip to first unread message

ebmajor

unread,
Feb 10, 2009, 7:56:10 PM2/10/09
to android-porting
Dear all,

I'm trying to understand how initramfs, especially 'init' program is
used as a root filesystem.
Usually I've used 'root=/dev/mtdblock0 rootfstype=jffs2' in kernel
command line for root filesystem and my 'init' program
is laid in mtdblock0 so kernel can find where the 'init' program
exists.

But I read initramfs does not required 'root=' command line.
So, if I don't type 'root=' in kernel command line, how the kernel
finds out where the 'init' program exists?
and what kind of filesystem is using for the block that 'init' program
exists?

Simply asking,
Can I use kernel command line without 'root=' option? If I can, how
can I use?

Sincerely.

Brian Swetland

unread,
Feb 11, 2009, 3:28:17 AM2/11/09
to android...@googlegroups.com

When booting with initramfs, the kernel creates a tmpfs at /, unpacking
the initramfs (typically a gzip'd cpio archive) into it. Then it runs
/init (I believe there is actually a short list of programs it tries to
run on / in a specific order, but I'd have to look at the kernel sources
to verify this).

It's expected that the init process started from initramfs will know how
to get everything else going. In the android world, this involves
/init.rc scripting what to mount where, etc.

Brian

[ebmajor <p...@innopath.com>]

Peter Oh

unread,
Feb 11, 2009, 1:20:50 PM2/11/09
to android...@googlegroups.com
Thank you a lot for your reply.

Now I'm almost clear except this one.
If I assume that I have initramfs file as the name of 'ramdisk.img'

How can android kernel find the location of 'ramdisk.img' exists?
If there is 'root=' option, kernel can try to find the location of 'ramdisk.img' from the location of 'root='.
But if kernel option does not have 'root=' option,
How kernel knows the location of ramdisk.img?

Does android kernel also usr 'root=' option to find out the location of 'ramdisk.img'?
Can I see what the typical 'Kernel command line' option for android is?

Really my best regards.
Peter Oh

Rizvan S

unread,
Feb 11, 2009, 1:35:38 PM2/11/09
to android...@googlegroups.com
HI,

As per my understanding this is not the case with android only, this is related to normal linux kernel.

Initramfs archive itself is a complete self-contained root filesystem for Linux.
In case of initramfs, the initramfs archive is linked in to the linux image only.
When you go for initramfs to boot kernel, ramdisk.img is part of kernel image rather than separate one.

Please check linux documents regarding initramfs.

Thanks
Rizavan
--
Thanks
Rizavan

Brian Swetland

unread,
Feb 12, 2009, 12:27:40 AM2/12/09
to android...@googlegroups.com

[Peter Oh <p...@innopath.com>]
>
> Thank you a lot for your reply.
>
> Now I'm almost clear except this one.
> If I assume that I have initramfs file as the name of 'ramdisk.img'

Yup. ramdisk.img is a gzip'd cpio image.

> How can android kernel find the location of 'ramdisk.img' exists?
> If there is 'root=' option, kernel can try to find the location of 'ramdisk.img' from the location of 'root='.
> But if kernel option does not have 'root=' option,
> How kernel knows the location of ramdisk.img?

The bootloader passes the ramdisk size and location via ATAGs.
See Documentation/arm/Booting in the linux kernel sources.

> Does android kernel also usr 'root=' option to find out the location of 'ramdisk.img'?
> Can I see what the typical 'Kernel command line' option for android is?

Nothing special really. I used "mem=101M console=ttyMSM2" on 7201A
SURF, for example.

Peter Oh

unread,
Feb 13, 2009, 6:06:55 PM2/13/09
to android...@googlegroups.com
Thanks! Brian,

This is my knowledge so far about initramfs.
To use initramfs as root filesystem,

1. initramfs.img is required to link with kernel image in the stage of kernel build
Using the kernel option CONFIG_INITRAMFS_SOURCE="ramdisk.img"

Using this option, kernel can link the ramdisk.img during the kernel build stage.
But I haven't verified it yet.

Regards.

Brian Swetland

unread,
Feb 13, 2009, 9:47:42 PM2/13/09
to android...@googlegroups.com

You can also pass the initramfs location and size to the kernel via
ATAGs in ARM builds. Please see my previous replies to this thread and
the arm booting documentation in the kernel docs directory.

[Peter Oh <p...@innopath.com>]
Reply all
Reply to author
Forward
0 new messages