Today I tried to mount a JFFS2 image at work. Normally you mount ISO files and other images like ‘mount test.img /mnt -o loop’. However, JFFS2 is not capable of mounting the image this way. So I searched a while before I found the right solution. Well, here it is :).
Be sure that your kernel supports MTD (memory technology) devices. If you use modules make sure you can insert the insmod mtdcore
module. Next, insert the following modules:
modprobe mtdram
modprobe mtdblock
The first module makes it possible that JFFS2 images are stored in the RAM memory, the second module enables the use of MTD devices as block devices. If your system is not able to insert them, compile them for your kernel. The same counts for JFFS2 filesystem support. Check if the kernel has JFFS2 support on board or as a module:
dmesg | grep jffs2
If this gives nothing back, try: modprobe jffs2
. If that also returns an error, rebuild your kernel with JFFS2 support! Now check if your system already has the right /dev entries:
ls -l /dev/mtd*
If no result, like /dev/mtdblock1
or /dev/mtdblock/1
is given, you have to make some new nodes for the MTD block devices:
mknod /dev/mtdblock0 b 31 0
mknod /dev/mtdblock1 b 31 1
mknod /dev/mtdblock2 b 31 2
You can copy the JFFS2 image to the block device (memory): dd if=/tmp/test.img of=/dev/mtdblock0
Now you should be able to mount the block device to a mount directory: mount -t jffs2 /dev/mtdblock0 /mnt/mtdblock0
That’s it, have fun with reading JFFS2 images.