创建 jffs2 文件系统
格式化jffs2文件系统
可以使用mkfs.jffs2或者flash_erase来对nor flash进行格式化。这个我们使用flash_erase,其用法如下:
~ # ./flash_erase --help
Usage:
MTD_DEVICE MTD device node or 'mtd:<name>'
flash_erase [options] MTD_DEVICE <start offset> <block count>
Erase blocks of the specified MTD device.
Specify a count of 0 to erase to end of device.
-j, --jffs2 format the device for jffs2
-N, --noskipbad don't skip bad blocks
-u, --unlock unlock sectors before erasing
-q, --quiet do not display progress messages
--silent same as --quiet
--help display this help and exit
--version output version information and exit
整个分区格式化为 jffs2 的命令为:
./flash_erase -j /dev/mtd1 0 0
注意:只需要格式化一次norflash,之后都不需要。
挂载jffs2 & overlay文件系统
参考文档:Overlay Filesystem — The Linux Kernel documentation
mkdir -p /overlay
mount -t jffs2 /dev/mtdblock1 /overlay
mkdir /overlay/etc_upper
mkdir /overlay/etc_work
mv /etc /etc_lower
mkdir /etc
mount -t overlay overlay -o lowerdir=/etc_lower,upperdir=/overlay/etc_upper,workdir=/overlay/etc_work /etc
其中:
/etc_lower:下层 etc 目录
/overlay/etc_upper:上层 etc 目录
/overlay/etc_work:工作 etc 目录(与 etc_upper 配合保证原子性,必须与 etc_upper 在同一文件系统)
/etc:合并后的 etc 目录