2000-10-31 03:07:31

by Matt Yourst

[permalink] [raw]
Subject: Re: / on ramfs, possible? [yes! - patch included]


I read your post and I think I have just what you're looking for. I've
attached a patch that allows you to mount root as ramfs and populate
it directly from a tar archive (specified just like an initrd image,
but without having to deal with a fixed-size initrd or pivot_root at
all.) This was based on some earlier work from the Linux router
project that I rewrote and ported to 2.2 and 2.4 a few months ago. I
didn't post it to the list since I figured it was too late for 2.4.0,
but if you're interested, here it is.

Here's the Configure.help description:

Allow the kernel to mount a ramfs namespace as the root filesystem
or as a pre-root filesystem for running a /linuxrc script (similar
to how initial RAM disk (initrd) support works.)

Since ramfs has no physical or virtual block device to provide its
data as an initrd image would, you must provide a standard tar
archive to be extracted into the empty ramfs root filesystem.
this tar archive may *not* be compressed (i.e., tar.gz style); if
compression is desired, use a bootloader with automatic gunzip
such as GRUB.

To specify the tar archive used to build the root filesystem, use
initrd=<filename> kernel command line option (except with a tar
instead of a real ext2/minix/romfs filesystem image.)

To mount the tar archive as the actual root filesystem, specify the
same initrd=<filename> option above and also include
in the kernel command line.

You may enable both this option and initrd support; however, if a
tar archive is detected instead of an initrd-supported filesystem
image, this option will override initrd support.

Note: Some versions of GNU tar create invalid archives that cannot
be extracted by the kernel. In particular, tar may add a file to an
archive without previously adding its containing directory. If your
ramfs archive does not mount correctly because of this, try creating
it in another way or with another file order.

(Patch should apply to 2.4.0-test10-pre6 on i386. It needs to be
updated for other architectures, mostly in setup.c though.)

I hope this is helpful. Maybe the maintainers would like to comment on
this too (i.e., might it be considered for 2.4.1, etc.?)

- Matt Yourst

Matt T. Yourst Massachusetts Institute of Technology
[email protected] 617.225.7690
513 French House - 476 Memorial Drive - Cambridge, MA 02136

linux-ramfs-tar-root.diff (18.95 kB)