Sat, 23 Dec 2006
I wanted to mount a jffs2 filesystem on my linux box (Ubuntu). It's actually the filesystem from my Zaurus 5500. My first attempt was:
# mount -t jffs2 -o loop initrd.bin r
It turns out that that is the wrong thing to do, and it results in the message:
mount: wrong fs type, bad option, bad superblock on /dev/loop/0, missing codepage or other error In some cases useful info is found in syslog - try dmesg | tail or so
and the following is in syslog:
Attempt to mount non-MTD device "/dev/loop/0" as JFFS2
It turns out that the correct incantation is something like:
Load the mtdram module to create a ramdisc of the correct size. The total_size and erase_size parameters are in KiB (1024 bytes), and you should try to be fairly accurate or make sure you have plenty of memory available. The filesystem I wanted to look at was 14680064 bytes, which is 14336 KiB.
# modprobe mtdram total_size=14336 erase_size=128
Check that worked OK:
# cat /proc/mtd dev: size erasesize name mtd0: 00e00000 00020000 "mtdram test device"
Then load the mtdblock module:
# modprobe mtdblock
Copy across the filesystem to the ramdisc:
# dd if=initrd.bin of=/dev/mtdblock0
Then do a loopback mount on the ramdisc:
# mount -t jffs2 /dev/mtdblock0 r
When you're done:
# umount r # modprobe -r mtdblock # modprobe -r mtdram