`
fanrey
  • 浏览: 251879 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

在linux pc上挂载jffs2文件系统(zz)

 
阅读更多
http://www.sourceware.org/jffs2/

zz from: http://blog.sina.com.cn/s/blog_4a4163880100cozw.html

因为jffs2是构建于MTD设备上的文件系统,所以无法通过loop设备来挂载,但是可以通过mtdram设备来挂载。mtdram是在用RAM实现的MTD设备,可以通过mtdblock设备来访问。使用mtdram设备很简单,只要加载mtdram和mtdblock两个内核模块即可。这两个内核模块一般的linux内核发行版都有编译好的,直接用modprobe命令加载。

  下面是在Fedora core 6环境下使用mtdram设备挂载jffs2根文件系统映像的具体步骤:

  1.加载mtdblock内核模块
  [root@localhost ~]# modprobe mtdblock

  2.加载mtdram内核模块,将该设备的大小指定为jffs2根文件系统映像的大小,块擦除大小(即flash的块大小)指定为制作该jffs2根文件系统时“-e”参数指定的大小,缺省为64KB。下面两个参数的单位都是KB。

  [root@localhost ~]# modprobe mtdram total_size=49152 erase_size=128

  3.这时将出现MTD设备/dev/mtdblock0,使用dd命令将jffs2根文件系统拷贝到/dev/mtdblock0设备中。

  [root@localhost prebuilt_bin]# dd if=rootfs.jffs2_zylonite_qvga of=/dev/mtdblock0
  98304+0 records in
  98304+0 records out
  50331648 bytes (50 MB) copied, 1.98391 seconds, 25.4 MB/s
步骤三也可以用以下等价的方法完成,更为简单:

[root@localhost ~]# cat roots.jffs2 >/dev/mtdblock0
  4.将保存了jffs2根文件系统的MTD设备挂载到指定的目录上。
  [root@localhost prebuilt_bin]# mount -t jffs2 /dev/mtdblock0 /mnt/mtd

  这之后就可以到/mnt/mtd目录查看、修改挂载的jffs2根文件系统了,修改后的jffs2根文件系统可以通过dd命令拷贝为一个jffs2的映像文件。




mkfs.jffs2参数详解

zz from: http://blog.sina.com.cn/s/blog_4a4163880100cogf.html

实例:mkfs.jffs2 -r rootfs -o rootfs.jffs2 -e 0x4000 --pad=0x1000000 -s 0x200 -n

mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree
Options:
-p, --pad[=SIZE] 用16進制來表示所要輸出檔案的大小,也就是root.jffs2 很重要的是, 為了不浪費flash空間, 這個值最好符合flash driver所規劃的區塊大小。如果不足则使用0xff来填充补满。
-r, -d, --root=DIR      指定要做成image的源資料夾.(默认:当前文件夹)
-s, --pagesize=SIZE     节点页大小(默认: 4KiB)
-e, --eraseblock=SIZE   设定擦除块的大小为(默认: 64KiB)
-c, --cleanmarker=SIZE Size of cleanmarker (default 12)
-m, --compr-mode=MODE   Select compression mode (default: priortiry)
-x, --disable-compressor=COMPRESSOR_NAME
                          Disable a compressor
-X, --enable-compressor=COMPRESSOR_NAME
                          Enable a compressor
-y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
                          Set the priority of a compressor
-L, --list-compressors Show the list of the avaiable compressors
-t, --test-compression Call decompress and compare with the original (for test)
-n, --no-cleanmarkers   指明不添加清楚标记(nand flash 有自己的校检块,存放相关的信息。)     如果挂载后会出现类似:
CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0
                          的警告,则加上-n 就会消失。
-o, --output=FILE       指定輸出image檔案的文件名.(default: stdout)
-l, --little-endian     指定使用小端格式
-b, --big-endian        指定使用大端格式
-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       将所有文件的拥有者设为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              显示这些文字
-v, --verbose           Verbose operation
-V, --version           显示版本
-i, --incremental=FILE Parse FILE and generate appendage output for it

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics