Gentoo Wiki ArchivesGentoo Wiki

JFFS2/Mounting

Contents

Purpose

There are a few reasons why this might be useful. Transparent Runtime Compression on a block device is one. Working with embedded systems is another.

Prepare the system

Emerge proper tools

This package didn't compile at the time of writing, because it was over 2 years old.

emerge sys-fs/mtd

An alternative is to download a binary of mkfs.jffs2 v1.17 for i386 Linux here. Another alternative is checkout the sources from the cvs at [1] Another alternative is to use sys-fs/mtd-utils since it will replace sys-fs/mtd, http://bugs.gentoo.org/show_bug.cgi?id=203279.

ACCEPT_KEYWORDS="~x86" emerge sys-fs/mtd-utils

Build your kernel with the proper MTD devices enabled

These modules need to be loaded (you can put them in modules.autoload) or just compile them right in.

Reboot the system now and ensure the modules are loaded

Make the device node block device

mknod /dev/mtdblock0 b 31 0

Make the initial image

This creates an empty folder that will become the root of the filesystem

mkdir /root/empty

Makes a jffs2 image, the --eraseblock=256000000 is number of bytes, in later versions of mkfs.jffs2 you can use sci notation

mkfs.jffs2 --root=/root/empty --eraseblock=256000000 --pad -o /jffs2drive.bin

Mount the image

Uses a loop to make the jffs2 image file a block device.

losetup /dev/loop0 /jffs2drive.bin or
losetup -o 16 /dev/loop0 /jffs2drive.bin

Tell the block2mtd driver what you want it to convert to a fake MTD device.

echo "/dev/loop0" > /sys/module/block2mtd/parameters/block2mtd

This will show if you have things set up right (size should be non-zero)

cat /proc/mtd

Finally mount the filesystem with the jffs2 filesystem type

mount -t jffs2 /dev/mtdblock0 /mnt/jffs2/

Block device disk speed comparisons

These were performed multiple times, the times represent the actual time of a typical run. Resier3 mounted loopback

centauri reiser3 # time tar xjf /usr/portage/distfiles/linux-2.6.17.tar.bz2
real    0m35.826s
user    0m27.710s
sys     0m5.252s

JFFS2 mounted loopback AND block2mtd. The additional time in sys is probably mostly due to the runtime compression.

centauri jffs2 # time tar xjf /usr/portage/distfiles/linux-2.6.17.tar.bz2
real    1m0.334s
user    0m28.594s
sys     0m24.894s
Retrieved from "http://www.gentoo-wiki.info/JFFS2/Mounting"

Last modified: Fri, 03 Oct 2008 13:15:00 +1000 Hits: 14,148

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.