23. Extracting a Zaurus ROM (MTD and JFFS2) filesystem

There are a number of ROM images that have been put together for the Sharp Zaurus. With some modification, these images make suitable disk images for the netBook. This chapter shows how to mount these ROM images and convert them to the usual ramdisk image.

23.1. MTD support on your system

The Zaurus ROM images use the jffs2 filesystem on MTD disks. I'm not quite sure what that means, but I think MTD is Memory Technology Device and jffs2 is a filesystem designed to work well and efficiently on MTD disks. In any case you will need mtd/jffs2 support on your desktop to access the Zaurus ROM image.

I started by reconfiguring my RedHat linux kernel to have the mtdcore, jffs2, mtdram, mtdchar and mtdblock modules. I recompiled and installed these modules. Later, I had a Suse 9.1 system, and all these things were available by default - nothing to do! Install these modules by:

  1. modprobe mtdcore

  2. modprobe jffs2

  3. modprobe mtdram total_size=32768 erase_size=256

  4. modprobe mtdchar

  5. modprobe mtdblock

  6. mknod /dev/mtdblock0 b 31 0

The /dev/mtdblock0 device was already available on my Suse 9.1 system; you may not need to make it.

The next two steps are easy:

  1. dd if=zaurus.initrd.bin of=/dev/mtdblock0

  2. mount -t jffs2 /dev/mtdblock0 /mnt/disk

where "zaurus.initrd.bin" is the Zaurus ROM image and "/mnt/disk" can be any convenient mount point. The ROM filesystem is now available in /mnt/disk.

23.2. Extracting the Zaurus filesystem

You now need to extract the stuff from /mnt/disk and put it into an ext2 initrd file. From "/mnt/disk" do:

  1. dd if=/dev/zero of=/tmp/boot.img bs=1024 count=57600

  2. mke2fs -m 3 /tmp/boot.img

  3. mount -t ext2 -o loop /tmp/boot.img /mnt/disk2

  4. tar cf - * | (cd /mnt/disk2 ; tar xf - )

where "/mnt/disk2" is another convenient mount point.

Now the Zaurus filesystem has been transfered to "/mnt/disk2" a ramdisk. You can then customize it for your own purposes there. Don't forget to unmount the mtd disk "/mnt/disk"; you are done with it.

When you are happy with your new ram disk, you should first repeat the steps above for making another ext2 ram disk ("/tmp/boot2.img" on "/mnt/disk3" ?) and tar the stuff from /mnt/disk2 to it. This will efficiently pack the filesystem; your modifications in /mnt/disk2 will have left a bunch of holes in the filesystem which will make the compressed initrd file unnecessarily large.

When you are ready, first change directory to where you want to save the new initrd. And then:

  1. umount /mnt/disk3

  2. cp /tmp/boot2.img initrd

  3. gzip -9 initrd

And you have your new initrd.gz file!