Ubifs文件系统和mkfs.ubifs以及ubinize工具的用法

转载地址:http://blog.sina.com.cn/s/blog_9452251d0102v482.html

http://blog.youkuaiyun.com/wjjontheway/article/details/8977871

Ubifs产生背景:

      无排序区块图像文件系统(Unsorted Block Image File System, UBIFS)是用于固态硬盘存储设备上,并与LogFS相互竞争,作为JFFS2的后继文件系统之一。真正开始开发于2007年,并于2008年10月第一次加入稳定版本于Linux核心2.6.27版。

UBIFS最早在2006年由IBM与Nokia的工程师Thomas Gleixner,Artem Bityutskiy所设计,专门为了解决MTD(Memory Technology Device)设备所遇到的瓶颈。由于Nand Flash容量的暴涨,YAFFS等皆无法再去控制Nand Flash的空间。UBIFS通过子系统UBI处理与MTD device之间的动作。与JFFS2一样,UBIFS 建构于MTD device 之上,因而与一般的block device不兼容。JFFS2运行在MTD设备之上,而UBIFS则只能工作于UBI volume之上。也可以说,UBIFS涉及了三个子系统:

 

1.MTD Subsystem:

 MTD 子系统, 提供对flash芯片的访问接口, MTD子系统提供了MTD device的概念,比如/dev/mtdx,MTD可以认为是raw flash。

2.UBI subsystem:

为flash device提供了wear-leveling和 volume management功能; UBI工作在MTD设备之上,提供了UBI volume;UBI是MTD设备的高层次表示,对上层屏蔽了一些MTD不得不处理的问题,比如wearing以及坏块管理。

 

3.UBIFS filesystem

 

UBIFS 文件系统,工作于UBI之上。

 

================================================================

mkfs.ubifs的用法 

Usage: mkfs.ubifs[OPTIONS] target 
Make a UBIFS file system image from an existing directorytree 
Examples: 
Build file system from directory /opt/img, writting the result inthe ubifs.img file 
       mkfs.ubifs -m 512 -e 128KiB -c 100 -r /opt/imgubifs.img 
The same, but writting directly to an UBIvolume 
       mkfs.ubifs -r /opt/img/dev/ubi0_0 
Creating an empty UBIFS filesystem on an UBIvolume 
       mkfs.ubifs/dev/ubi0_0 

Options: 
-r, -d, --root=DIR             build file system fromdirectory DIR 
-m, --min-io-size=SIZE      minimum I/O unitsize,最小输入输出大小 
-e, --leb-size=SIZE       logicalerase block size逻辑可擦出块大小 
-c, --max-leb-cnt=COUNT   maximum logical erase blockcount最大逻辑可擦出块数目 
-o, --output=FILE       outputto FILE输出文件名 
-j, --jrn-size=SIZE     journalsize 
-R, --reserved=SIZE     howmuch space should be reserved for thesuper-user 
-x, --compr=TYPE       compressiontype - "lzo", "favor_lzo", "zlib" or 
                             "none" (default:"lzo") 
-X, --favor-percent      may only be used with favor LZO compression anddefines 
                           how many percentbetter zlib should compress to make 
                           mkfs.ubifsuse zlib instead of LZO (default 20%) 

-f, --fanout=NUM        fanout NUM (default: 8) 
-F, --space-fixup        file-system free space has tobe fixed up on first moun
                      (requires kernel version 3.0 orgreater) 
-k, --keyhash=TYPE      key hash type - "r5" or "test" (default:"r5") 
-p, --orph-lebs=COUNT     countof erase blocks for orphans (default: 1) 
-D, --devtable=FILE      use device table FILE 
-U, --squash-uids        squash owners making allfiles owned by root 
-l, --log-lebs=COUNT    count of eraseblocks for the log (used onlyfor debugging) 
-v, --verbose           verbose operation 
-V, --version           display versioninformation 
-g, --debug=LEVEL        display debug information (0- none, 1 - statistics, 2 - files, 3 - moredetails) 
-h, --help             displaythis help text 

 

例: 
mkfs.ubifs -x lzo -m 2KiB -e 124KiB -c 720 -osystem_ubifs.img -d$path_to_system 
压缩格式为lzo 
-m最小输入输出大小为2KiB(2048bytes),一般为页大小 
-e逻辑可擦除块大小为124KiB=(每块的页数-2)*页大小=(64-2)*2KiB=124KiB 
-c最多逻辑可擦除块数目为720(720*128KiB=90MiB),这个可根据ubivolume来设置,实际上是设置此卷的最大容量。 

========================================================================================

ubinize的用法

Usage: ubinize [-ofilename] [-p ] [-m ] [-s ] [-O ] [-e 
][-x  ]  [-Q  ] [-v]  [-h] [-V] [--output=] 
[--peb-size=]  [--min-io-size=] [--sub-page-size=] 
[--vid-hdr-offset=]  [--erase-counter=] [--ubi-ver=] 
[--image-seq=] [--verbose] [--help] [--version]ini-file 
Example: ubinize -o ubi.img -p 16KiB -m 512 -s 256 cfg.ini - createUBI image 
        'ubi.img' as described byconfiguration file'cfg.ini' 

-o, --output=    output filename 
-p, --peb-size=      size of the physical eraseblock of theflash 
                         thisUBI image is created for in bytes, 
                          kilobytes(KiB), or megabytes (MiB) 
                          (mandatoryparameter)物理可擦出块大小 
-m, --min-io-size=    minimuminput/output unit size of the flash 
                         inbytes 
-s, --sub-page-size=  minimum input/output unitused for UBI 
                         headers,e.g. sub-page size in case of NAND 
                         flash(equivalent to the minimum input/output 
                         unitsize by default)子页大小 

-O,--vid-hdr-offset=   offset if the VID header fromstart of the 
                          physicaleraseblock (default is the next 
                         minimumI/O unit or sub-page after the EC 
                         header)VID头部偏移量,默认是512 
-e, --erase-counter=    the erasecounter value to put to EC headers (default is0) 
-x, --ubi-ver=          UBIversion number to put to ECheaders  (default is1) 
-Q, --image-seq=       32-bit UBI image sequencenumber to use 
                         (bydefault a random number is picked) 
-v, --verbose               beverbose 
-h, --help                printhelp message 
-V, --version               printprogram version 

例: 
ubinize –o ubi.img -m 2KiB -p 128KiB -s 2048$system_cfg_file –v 
-m最小输入输出大小为2KiB(2048bytes),一般为页大小 
-p物理可擦出块大小为128KiB=每块的页数*页大小=64*2KiB=128KiB 
-s用于UBI头部信息的最小输入输出单元,一般与最小输入输出单元(-m参数)大小一样。 
ubinize需要指定一个配置文件$system_cfg_file,内容如下: 
[rootfs-volume]  
mode=ubi  
image=system_ubifs.img  
vol_id=0  
vol_size=90MiB  
vol_type=dynamic 
vol_name=system 

======================================================================

配置文件说明 
INI-file format. 
The input configuration ini-file describes all the volumes whichhave to 
be included to the output UBI image. Each volume is described inits own 
section which may be named arbitrarily. The section consistson 
"key=value" pairs, for example: 
 
[jffs2-volume] 
mode=ubi 
image=../jffs2.img       mkfs.ubi生成的源镜像 
vol_id=1                卷序号 
vol_size=30MiB        卷大小 
vol_type=dynamic         动态卷 
vol_name=jffs2_volume     卷名 
vol_flags=autoresize     
vol_alignment=1 

 

This exampleconfiguration file tells the utility to create an UBIimage with one volume with ID 1, volume size30MiB, the volume is dynamic, has name"jffs2_volume", "autoresize" volume flag, and alignment 1.The "image=../jffs2.img" line tells the utility totake the contents of the volume from the"../jffs2.img" file. The size of the image file has tobe less or equivalent to the volume size (30MiB).The "mode=ubi" line is mandatory and just tellsthat the section describes an UBI volume -other section modes may be added in thefuture. 
Notes: 

 * size in vol_size might be specified kilobytes (KiB), megabytes(MiB),  gigabytes (GiB) or bytes(no modifier); 
  * if "vol_size" key is absent, the volume sizeis assumed to be equivalent to the size of theimage file (defined by "image" key); 
  * if the "image" is absent, the volume isassumed to be empty; 

 

 * volume alignment must not be greater than the logical eraseblocksize; 
  * one ini file may contain arbitrary number ofsections, the utility will put all the volumeswhich are described by these section to the         output UBI imagefile.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值