nuc972文件系统说明
mkfs.ubifs -x lzo -m 2KiB -e 124KiB -c 720 -o system_ubifs.img -d $path_to_system
-m 最小I/O单元大小,一般是页大小, 2048 byte
-r 是指定哪个文件系统作为文件系统。
-e 是可擦除逻辑块大小,一般等于 (每块的页数 - 2)* 页大小 = (64byte - 2) * 4096 == 124KiB
-c最多逻辑可擦除块数目为720(720*128KiB=90MiB),这个可根据ubi volume来设置,实际上是设置此卷的最大容量。
ubinize -o ubi.img -m 2048 -p 128KiB -s 512 -O 2048 ubinize.cfg
-p 指定flash的物理擦除块大小
-m 指定flash的最小输入输出单元,当为nor flash时,此值应指定为1,当为nand flash时此值应指定为页面大小
-s 指定子页大小,当为nor flash时,此值应指定为1,当为nand flash时需指定此值为nand flash的子页大小
https://blog.csdn.net/looooooooop/article/details/8119881
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 mount
(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)
-y, --yes assume the answer is "yes" for all questions
-v, --verbose verbose operation
-V, --version display version information
-g, --debug=LEVEL display debug information (0 - none, 1 - statistics,
2 - files, 3 - more details)
-a, --set-inum-attr create user.image-inode-number extended attribute on files
added to the image. The attribute will contain the inode
number the file has in the generated image.
-h, --help display this help text
Note, SIZE is specified in bytes, but it may also be specified in Kilobytes,
Megabytes, and Gigabytes if a KiB, MiB, or GiB suffix is used.
If you specify "lzo" or "zlib" compressors, mkfs.ubifs will use this compressor
for all data. The "none" disables any data compression. The "favor_lzo" is not
really a separate compressor. It is just a method of combining "lzo" and "zlib"
compressors. Namely, mkfs.ubifs tries to compress data with both "lzo" and "zlib"
compressors, then it compares which compressor is better. If "zlib" compresses 20
or more percent better than "lzo", mkfs.ubifs chooses "lzo", otherwise it chooses
"zlib". The "--favor-percent" may specify arbitrary threshold instead of the
default 20%.
The -F parameter is used to set the "fix up free space" flag in the superblock,
which forces UBIFS to "fixup" all the free space which it is going to use. This
option is useful to work-around the problem of double free space programming: if the
flasher program which flashes the UBI image is unable to skip NAND pages containing
only 0xFF bytes, the effect is that some NAND pages are written to twice - first time
when flashing the image and the second time when UBIFS is mounted and writes useful
data there. A proper UBI-aware flasher should skip such NAND pages, though. Note, this
flag may make the first mount very slow, because the "free space fixup" procedure
takes time. This feature is supported by the Linux kernel starting from version 3.0.
一般计算的方式
-m minimum I/O unit size 页大小 2048 byte
-e logical erase block size,
逻辑擦除块大小=物理擦除块大小-EC头结构体大小-VID头结构体大小
(EC头和VID头是ubi中的概念,这两个结构体描述逻辑擦除块的相关信息;这是nor flash中的逻辑擦除块的计算方法,
那么nand flash的逻辑擦除块大小如何计算呢?请看拓展) 那么128KiB-64B-64B=130944
-e 是可擦除逻辑块大小,一般等于 (每块的页数 - 2)* 页大小 = (64byte - 2) * 4096 == 124KiB=126976
-c, --max-leb-cnt=COUNT maximum logical erase block count
-c最多逻辑可擦除块数目为720(720*128KiB=90MiB),这个可根据ubi volume来设置,实际上是设置此卷的最大容量。
mkfs.ubifs -F -m 2048 -e 126976 -c 720 -o rootfs.img -r rootfs
ubinize -o ubi.img -m 2048 -p 131072 -s 2048 -O 2048 ubinize.cfg
[ubifs]
mode=ubi
image=ubifs.img
vol_id=
vol_size=100MiB
vol_type=dynamic
vol_alignment=1
vol_name=rootfs
vol_flags=autoresize
ubinize
Usage: ubinize [options]
Generate UBI images. An UBI image may contain one or more UBI volumes which
have to be defined in the input configuration ini-file. The flash
characteristics are defined via the command-line options.
-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)
-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
For more information see `man 8 ubinize`
一般计算的方式
-p 物理擦写大小,一般是块大小 128Kib=131072 字节
-m 最小的io单元,一般是页大小 2048 字节
-s 子页大小,有些nand有子页,就是一个大页由多个子页组成的