Re: How to change the root filesystem

Daniel Quinlan (quinlan@transmeta.com)
24 Jul 2001 00:58:38 -0700


xinyuepeng@yahoo.com writes:

> I want change the root filesystem from ext2 to cramfs, I read the
> init code about the filesystem. But I cannot understand how to make
> a device that is used as cramfs device.

(I asked: "desktop system?" Reply: "No! embedded system!" So, here's
the answer.)

cramfs should work out of the box as the root filesystem. I'm not
sure what you mean by "make a device". cramfs is meant to be used on
a block device like ext2 such as /dev/hda1.

If you want to include the kernel on the root filesystem, it's a bit
more complicated.

Option 1

- use Midori Linux: http://midori.transmeta.com/

Option 2

You need a few things:

- linux 2.4.7 kernel
- mkcramfs version from linux 2.4.7
- cramfsboot (part of Midori Linux) which is located here:
http://midori.transmeta.com/pub/midori-1.0.0-beta2/apps/
(includes an MBR, the cramfs secondary loader, set_boot, and
make_active)

Run mkcramfs with a command line of something like:

mkcramfs -E -p -i bzImage -z root root.img.cram

where bzImage is the kernel, root is the directory to cram, and
root.img.cram is the output. Actually, it's worse than that because
cramfsboot wants the kernel to start 1024 bytes from the beginning of
the partition.

dd if=/dev/zero of=bzImage.padded bs=436c count=1
cat bzImage >> bzImage.padded
mkcramfs -E -p -i bzImage.padded -z root roott.img.cram
cp cramfsboot.bin root1.img.cram # from cramfsboot
tail +513c roott.img.cram >> root1.img.cram
cramfsck root1.img.cram
set_boot root1.img.cram 1
rm roott.img.cram

Then root1.img.cram can be put on the first partition of say a Compact
Flash or other IDE device. You will need to use the MBR that's
included with cramfsboot and don't forget to set the active flag (the
cramfsboot MBR uses it).

This code is a much-simplified version of what's in the Midori Linux
"mlbuild" package. (I haven't tried the simplified version, so if you
need more help, please refer to the mlbuild package, same location as
the cramfsboot package.)

It sounds like you're just getting started on your embedded system,
though, so I'd strongly recommend looking at what's out there. Midori
Linux makes heavy use of cramfs, but a bunch of the other offerings
also use cramfs.

- Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/