JFFS2/Mounting
From Gentoo Linux Wiki
Contents |
[edit] 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.
[edit] Prepare the system
[edit] 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
[edit] 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.
- "Device Drivers"
- "Block Devices"
- "Loopback Device Support" (loop)
- "Memory Technology Device (MTD) support"
- "Caching block device access to MTD devices" (mtdblock module) (required for block2mtd)
- "Self-contained MTD device drivers..."
- "MTD emulation using block device" (block2mtd),
- "Block Devices"
- "File Systems"
- "Miscellaneous Filesystems"
- "Journalling Flash File System v2 (JFFS2) support"
- "Advanced compression options for JFFS2"
- "JFFS2 ZLIB compression support"
- "Advanced compression options for JFFS2"
- "Journalling Flash File System v2 (JFFS2) support"
- "Miscellaneous Filesystems"
Reboot the system now and ensure the modules are loaded
[edit] Make the device node block device
mknod /dev/mtdblock0 b 31 0
[edit] 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
[edit] 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/
[edit] 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
