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 directory tree
Examples:
Build file system from directory /opt/img, writting the result in the ubifs.img file
mkfs.ubifs -m 512 -e 128KiB -c 100 -r /opt/img ubifs.img
The same, but writting directly to an UBI volume
mkfs.ubifs -r /opt/img /dev/ubi0_0
Creating an empty UBIFS filesystem on an UBI volume
mkfs.ubifs /dev/ubi0_0
Options:
-r, -d, --root=DIR build file system from directory DIR
-m, --min-io-size=SIZE minimum I/O unit size,最小输入输出大小
-e, --leb-size=SIZE logical erase block size逻辑可擦出块大小
-c, --max-leb-cnt=COUNT maximum logical erase block count最大逻辑可擦出块数目
-o, --output=FILE output to FILE输出文件名
-j, --jrn-size=SIZE journal size
-R, --reserved=SIZE how much space should be reserved for the super-user
-x, --compr=TYPE compression type - "lzo", "favor_lzo", "zlib" or
"none" (default: "lzo")
-X, --favor-percent may only be used with favor LZO compression and defines
how many percent better zlib should compress to make
mkfs.ubifs use zlib instead of LZO (default 20%)
-f, --fanout=NUM fanout NUM (default: 8)
-F, --space-fixup file-system free space has to be fixed up on first moun
(requires kernel version 3.0 or greater)
-k, --keyhash=TYPE key hash type - "r5" or "test" (default: "r5")
-p, --orph-lebs=COUNT count of erase blocks for orphans (default: 1)
-D, --devtable=FILE use device table FILE
-U, --squash-uids squash owners making all files owned by root
-l, --log-lebs=COUNT count of erase blocks for the log (used only for debugging)
-v, --verbose verbose operation
-V, --version display version information
-g, --debug=LEVEL display debug information (0 - none, 1 - statistics, 2 - files, 3 - more details)
-h, --help display this help text
例:
mkfs.ubifs -x lzo -m 2KiB -e 124KiB -c 720 -o system_ubifs.img -d $path_to_system
压缩格式为lzo
-m最小输入输出大小为2KiB(2048bytes),一般为页大小
-e逻辑可擦除块大小为124KiB=(每块的页数-2)*页大小=(64-2)*2KiB=124KiB
-c最多逻辑可擦除块数目为720(720*128KiB=90MiB),这个可根据ubi volume来设置,实际上是设置此卷的最大容量。
========================================================================================
ubinize的用法
Usage: ubinize [-o filename] [-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 - create UBI image
'ubi.img' as described by configuration file 'cfg.ini'
-o, --output= output file name
-p, --peb-size= size of the physical eraseblock of the flash
this UBI image is created for in bytes,
kilobytes (KiB), or megabytes (MiB)
(mandatory parameter)物理可擦出块大小
-m, --min-io-size= minimum input/output unit size of the flash
in bytes
-s, --sub-page-size= minimum input/output unit used for UBI
headers, e.g. sub-page size in case of NAND
flash (equivalent to the minimum input/output
unit size by default)子页大小
-O, --vid-hdr-offset= offset if the VID header from start of the
physical eraseblock (default is the next
minimum I/O unit or sub-page after the EC
header)VID头部偏移量,默认是512
-e, --erase-counter= the erase counter value to put to EC headers (default is 0)
-x, --ubi-ver= UBI version number to put to EC headers (default is 1)
-Q, --image-seq= 32-bit UBI image sequence number to use
(by default a random number is picked)
-v, --verbose be verbose
-h, --help print help message
-V, --version print program 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 which have to
be included to the output UBI image. Each volume is described in its own
section which may be named arbitrarily. The section consists on
"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 example configuration file tells the utility to create an UBI image with one volume with ID 1, volume size 30MiB, the volume is dynamic, has name "jffs2_volume", "autoresize" volume flag, and alignment 1. The "image=../jffs2.img" line tells the utility to take the contents of the volume from the "../jffs2.img" file. The size of the image file has to be less or equivalent to the volume size (30MiB). The "mode=ubi" line is mandatory and just tells that the section describes an UBI volume - other section modes may be added in the future.
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 size is assumed to be equivalent to the size of the image file (defined by "image" key);
* if the "image" is absent, the volume is assumed to be empty;
* volume alignment must not be greater than the logical eraseblock size;
* one ini file may contain arbitrary number of sections, the utility will put all the volumes which are described by these section to the output UBI image file.
转载自:http://blog.sina.com.cn/s/blog_9452251d0102v482.html
阅读(7724) | 评论(0) | 转发(1) |