What is JFFS2 ?
=> JFFS2 is a log-structured file system designed for use on flash devices in embedded systems. Rather than using a kind of translation layer on flash devices to emulate a normal hard drive, as is the case with older flash solutions, it places the filesystem directly on the flash chips.
JFFS2 was developed by Red Hat, based on the work started in the original JFFS by Axis Communications, AB.
How to create jffs2 target image on ubuntu ?
Lets say you have your root filesystem in directory /home/myuser/rfs . The jffs2 target image can be created using mkfs.jffs2 which is part of mtdutils, hence we need to first install mtdutils as,
$ sudo apt install mtd-utils
[sudo] password for myuser:
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 399 not upgraded.
Need to get 181 kB of archives.
After this operation, 846 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe i386 mtd-utils i386 1:1.5.2-1 [181 kB]
Fetched 181 kB in 1s (140 kB/s)
Selecting previously unselected package mtd-utils.
(Reading database … 475226 files and directories currently installed.)
Preparing to unpack …/mtd-utils_1%3a1.5.2-1_i386.deb …
Unpacking mtd-utils (1:1.5.2-1) …
Processing triggers for man-db (2.7.5-1) …
Setting up mtd-utils (1:1.5.2-1) …
$ mkfs.jffs2 --help
mkfs.jffs2: error!: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree
-p, –pad[=SIZE] Pad output to SIZE bytes with 0xFF. If SIZE is
not specified, the output is padded to the end of
the final erase block
-r, -d, –root=DIR Build file system from directory DIR (default: cwd)
-s, –pagesize=SIZE Use page size (max data node size) SIZE.
Set according to target system’s memory management
page size (default: 4KiB)
-e, –eraseblock=SIZE Use erase block size SIZE (default: 64KiB)
-c, –cleanmarker=SIZE Size of cleanmarker (default 12)
-m, –compr-mode=MODE Select compression mode (default: priority)
Disable a compressor
Enable a compressor
Set the priority of a compressor
-L, –list-compressors Show the list of the available compressors
-t, –test-compression Call decompress and compare with the original (for test)
-n, –no-cleanmarkers Don’t add a cleanmarker to every eraseblock
-o, –output=FILE Output to FILE (default: stdout)
-l, –little-endian Create a little-endian filesystem
-b, –big-endian Create a big-endian filesystem
-D, –devtable=FILE Use the named FILE as a device table file
-f, –faketime Change all file times to ‘0’ for regression testing
-q, –squash Squash permissions and owners making all files be owned by root
-U, –squash-uids Squash owners making all files be owned by root
-P, –squash-perms Squash permissions on all files
–with-xattr stuff all xattr entries into image
–with-selinux stuff only SELinux Labels into jffs2 image
–with-posix-acl stuff only POSIX ACL entries into jffs2 image
-h, –help Display this help text
-v, –verbose Verbose operation
-V, –version Display version information
-i, –incremental=FILE Parse FILE and generate appendage output for it
Now as we need to set few options as below, important in one of this is the size of eraseblocks.
$ mkfs.jffs2 -n -p -e 128KiB -b -d /home/myuser/rfs -o myrfs.jffs2
Reference : http://sourceware.org/jffs2/