ubi命令用法(linux)
原文网址:ubi命令用法(linux)_IT利刃出鞘的博客-CSDN博客_ubi命令
简介
内核启动后,会自动创建/dev/ubi_ctrl、/sys/class/misc/ubi_ctrl、/sys/class/ubi/version。
本部分命令所在软件包:ubi-utils
ubinfo
作用 |
提供从系统中找到的UBI设备、UBI卷的相关信息 |
格式 |
|
参数 |
|
-d, --devn=<UBI device number> |
UBI device number to get information about |
-n, --vol_id=<volume ID> |
ID of UBI volume to print information about |
-N, --name=<volume name> |
name of UBI volume to print information about |
-a, --all |
print information about all devices and volumes,or specified |
-h, --help |
print help message |
-V, --version |
print program version |
示例 |
|
ubinfo - (no arguments) print general UBI information ubinfo -d 1 - print information about UBI device number 1 ubinfo /dev/ubi0 -a - print information about all volumes of UBI device /dev/ubi0 ubinfo /dev/ubi1_0 - print information about UBI volume /dev/ubi1_0 ubinfo -a - print all information |
ubiformat
作用 |
格式化MTD设备,擦除Flash,保存擦除计数,写入UBI镜像到Flash; flash_erase命令有类似的效果。 详细操作: 1.从/sys/class/mtd/mtdN下的节点中读数据 3. 扫描所有块: 检查坏块、读出EC header、检查是否为ubi块、记录擦除次数 EC header是在一个擦除块的开头,而VID header的位置有几个情况: 若是nor flash有1字节操作单元,通常VID header的位置在偏移64字节处 |
格式 |
ubiformat <MTD device node file name> [-s <bytes>] [-O <offs>] [-n] [-Q <num>] [-f <file>] [-S <bytes>] [-e <value>] [-x <num>] [-y] [--vid-hdr-offset=<offs>] [--no-volume-table][--flash-image=<file>] [--image-seq=<num>] [--ubi-ver=<num>] [--yes] [--quiet] [--verbose] [--help] [--version] |
参数 |
|
-s, --sub-page-size=<bytes> |
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=<offs> |
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) |
-n, --no-volume-table |
only erase all eraseblock and preserve erase counters, do not write empty volume table |
-f, --flash-image=<file> |
flash image file, or '-' for stdin |
-S, --image-size=<bytes> |
bytes in input, if not reading from file |
-e, --erase-counter=<value> |
use <value> as the erase counter value for all eraseblocks |
-x, --ubi-ver=<num> |
UBI version number to put to EC headers (default is 1) |
-Q, --image-seq=<num> |
32-bit UBI image sequence number to use (by default a random number is picked) |
-y, --yes |
assume the answer is "yes" for all question this program would otherwise ask |
-q, --quiet |
suppress progress percentage information |
-v, --verbose |
be verbose |
-h, -?, --help |
print help message |
-V, --version |
print program version |
示例 |
|
ubiformat /dev/mtd0 -y - format MTD device number 0 and do not ask questions. ubiformat /dev/mtd0 -q -e 0 - format MTD device number 0, be quiet and force erase counter value 0. ubiformat /dev/mtd8 -s 2048 -O 2048 ubiformat: mtd8 (nand), size 41943040 bytes (40.0 MiB), 320 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes nanddump -p -c -s 0 -l 4096 /dev/mtd8 |
ubiattach
作用 |
链接MTD设备(MTD设备描述原始Flash设备)到UBI并且创建相应的UBI设备。 attach通过ioctl系统调用,执行内核的UBI_IOCATT操作,内核中执行attach的主要函数是ubi_attach_mtd_dev。 详细操作: 5. 创建一个ubi设备(struct ubi_device),设备节点为/dev/ubiN 会创建/dev/ubiN节点 以及 /sys/class/ubi/ubiN目录 |
格式 |
ubiattach [<UBI control device node file name>] [-m <MTD device number>] [-d <UBI device number>] [-p <path to device>] [--mtdn=<MTD device number>] [--devn=<UBI device number>] [--dev-path=<path to device>] [--max-beb-per1024=<maximum bad block number per 1024 blocks>] UBI control device defaults to /dev/ubi_ctrl if not supplied. |
参数 |
|
-d, --devn=<number> |
the number to assign to the newly created UBI device (assigned automatically if this is not specified) |
-p, --dev-path=<path> |
path to MTD device node to attach |
-m, --mtdn=<number> 此选项是必须的 |
MTD device number to attach (alternative method, e.g if the character device node does not exist) 。 |
-O, --vid-hdr-offset |
VID header offset (do not specify this unless you really know what you are doing, the default should be optimal) |
-b, --max-beb-per1024 |
maximum expected bad block number per 1024 eraseblock. Allowed range is 0-768, 0 means the default kernel value. |
-h, --help |
print help message |
-V, --version |
print program version |
示例 |
|
ubiattach -p /dev/mtd0 - attach /dev/mtd0 to UBI //等价于 ubiattach -m 0 ubiattach -m 0 - attach MTD device 0 (mtd0) to UBI ubiattach -m 0 -d 3 - attach MTD device 0 (mtd0) to UBI and create UBI device number 3 (ubi3) ubiattach -m 1 -b 25 - attach /dev/mtd1 to UBI and reserve 25*C/1024 eraseblocks for bad block handling, where C is the flash is total flash chip eraseblocks count, that is flash chip size in eraseblocks (including bad eraseblocks). E.g., if the flash chip has 4096 PEBs, 100 will be reserved. 实例: ubiattach -m 8 -d 1 执行结果: [ 366.634630] ubi1: attaching mtd8 flash physical eraseblock size:从flash芯片手册中可以得到FLASH物理擦除块大小,或cat /proc/mtd sub-page size: 通过flash手册获得 logical eraseblock size: 对于没有子页的NAND FLASH来说:等于peb(物理擦除块大小) 对于有子页的NAND FLASH来说,等于“物理擦除块大小-1页的大小” |
ubidetach
作用 |
ubiattach相反的操作,将MTD设备从UBI设备上去链接。 注意,在使用此命令之前,先要umount掉。 |
格式 |
ubidetach [<UBI control device node file name>] [-d <UBI device number>] [-m <MTD device number>] [-p <path to device>] [--devn=<UBI device number>] [--mtdn=<MTD device number>] [--dev-path=<path to device>] UBI control device defaults to /dev/ubi_ctrl if not supplied. |
参数 |
|
-d, --devn=<number> |
the number to assign to the newly created UBI device (assigned automatically if this is not specified) |
-p, --dev-path=<path> |
path to MTD device node to attach |
-m, --mtdn=<number> |
MTD device number to attach (alternative method, e.g if the character device node does not exist) |
-O, --vid-hdr-offset |
VID header offset (do not specify this unless you really know what you are doing, the default should be optimal) |
-b, --max-beb-per1024 |
maximum expected bad block number per 1024 eraseblock. The default value is correct for most NAND devices. Allowed range is 0-768, 0 means the default kernel value. |
-h, --help |
print help message |
-V, --version |
print program version |
示例 |
|
ubidetach -p /dev/mtd0 - detach MTD device /dev/mtd0 ubidetach -d 2 - delete UBI device 2 (ubi2) ubidetach -m 0 - detach MTD device 0 (mtd0) |
ubimkvol
作用 |
从UBI设备上创建UBI卷。 详细操作: 其实ubiattach要分两种情况:mtd设备已经有制作卷了,或者是没有制作卷。判断依据就是VIDheader里面的卷ID。 |
格式 |
ubimkvol <UBI device node file name> [-h] [-a <alignment>] [-n <volume ID>] [-N <name>] [-s <bytes>] [-S <LEBs>] [-t <static|dynamic>] [-V] [-m] [--alignment=<alignment>][--vol_id=<volume ID>] [--version] [--maxavsize] |
参数 |
|
-a, --alignment=<alignment> |
volume alignment (default is 1) |
-n, --vol_id=<volume ID> |
UBI volume ID, if not specified, the volume ID will be assigned automatically |
-N, --name=<name> |
volume name |
-s, --size=<bytes> |
volume size volume size in bytes, kilobytes (KiB) or megabytes (MiB) |
-S, --lebs=<LEBs count> |
alternative way to give volume size in logical eraseblocks |
-m, --maxavsize |
set volume size to maximum available size |
-t, --type=<static|dynamic> |
volume type (dynamic, static), default is dynamic |
-h, -?, --help |
print help message |
-V, --version |
print program version |
示例 |
|
ubimkvol /dev/ubi0 -s 20MiB -N config_data - create a 20 Megabytes volume named "config_data" on UBI device /dev/ubi0. ubimkvol /dev/ubi1 -N app_pri -m Set volume size to 37584896 |
ubirmvol
作用 |
从UBI设备上删除UBI卷 |
格式 |
ubirmvol <UBI device node file name> [-n <volume id>] |
参数 |
|
-a, --alignment=<alignment> |
volume alignment (default is 1) |
-m, --maxavsize |
set volume size to maximum available size |
-n, --vol_id=<volume id> |
volume ID to remove |
-N, --name=<volume name> |
volume name to remove |
-h, -?, --help |
print help message |
-s, --size=<bytes> |
volume size volume size in bytes, kilobytes (KiB) or megabytes (MiB) |
-S, --lebs=<LEBs count> |
alternative way to give volume size in logical eraseblocks |
-t, --type=<static|dynamic> |
volume type (dynamic, static), default is dynamic |
-h, -?, --help |
print help message |
-V, --version |
print program version |
示例 |
|
ubirmvol /dev/ubi0 -n 1 - remove UBI volume 1 from UBI device corresponding to /dev/ubi0 ubirmvol /dev/ubi0 -N my_vol - remove UBI named "my_vol" from UBI device corresponding to /dev/ubi0 |
ubinize
作用 |
制作UBI镜像 |
格式 |
ubinize [-o filename] [-p <bytes>] [-m <bytes>] [-e <num>] [-x <num>] [-Q <num>] [-v] [-h] [-V] [--output=<filename>] [--peb-size=<bytes>] [--min-io-size=<bytes>] [--sub-page-size=<bytes>] [--vid-hdr-offset=<num>] [--erase-counter=<num>] [--ubi-ver=<num>] [--image-seq=<num>] [--verbose] [--help] [--version] ini-file |
参数 |
|
-o, --output=<file name> |
output file name |
-p, --peb-size=<bytes> |
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=<bytes> |
minimum input/output unit size of the flash in bytes |
-s, --sub-page-size=<bytes> |
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=<num> |
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=<num> |
the erase counter value to put to EC headers (default is 0) |
-x, --ubi-ver=<num> |
UBI version number to put to EC headers (default is 1) |
-Q, --image-seq=<num> |
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 -p 16KiB -m 512 -s 256 cfg.ini - create UBI image 'ubi.img' as described by configuration file 'cfg.ini' |
ubiblock
作用 |
管理UBI卷上的block(创建/删除) |
格式 |
ubiblock [-c,-r] <UBI volume node file name> |
参数 |
|
-c, --create |
create block on top of a volume |
-r, --remove |
remove block from volume |
-h, --help |
print help message |
-V, --version |
print program version |
示例 |
|
ubiblock --create /dev/ubi0_0 |
ubirename
作用 |
更改ubi某个olume的名字,或者完成两个volume的互换 |
格式 |
ubirename <UBI device node file name> [<old name> <new name>|...] |
示例 |
|
1. 将ubi2上名字为my_vol_a的volume名字改为my_vol_newname ubirename /dev/ubi2 my_vol_a my_vol_newname 2. 将ubi2上名字为my_vol_b和my_vol_c的两个volume互换, ubirename /dev/ubi2 my_vol_b my_vol_c my_vol_c my_vol_b 3. 把volume A的名字改为B,把volume C的名字改为D ubirename/dev/ubi0 A B C D |
ubiupdatevol
作用 |
向UBI volume里边写数据 |
格式 |
ubiupdatevol <UBI volume node file name> [-t] [-s <size>] [-h] [-V] [--truncate] [--size=<size>] [--help] [--version] <image file> |
参数 |
|
-t, --truncate |
truncate volume (wipe it out) |
-s, --size=<bytes> |
bytes to read from input |
--skip=<bytes> |
leading bytes to skip from input |
-h, --help |
print help message |
-V, --version |
print program version |
示例 |
|
1. write file "fs.img" to UBI volume /dev/ubi0_1 ubiupdatevol /dev/ubi0_1 fs.img 2. wipe out UBI volume /dev/ubi0_1 ubiupdatevol /dev/ubi0_1 -t |
操作示例
第一次操作
ubiformat /dev/mtd8 -s 0x800 -O 0x800
ubiattach -m 8 -d 1 /dev/ubi_ctrl //会出现/dev/ubi1节点
ubimkvol /dev/ubi1 -N app_pri -m //会出现/dev/ubi1_0节点
mount -t ubifs /dev/ubi1_0 /mnt
//注意:ubiattach 生成/dev/ubiM和ubimkvol生成/dev/ubiM_N需要时间,要等待其生成节点之后再mount
示例等待命令(shell):
/usr/sbin/ubiattach -m 8 -d 1 /dev/ubi_ctrl
if [ $? == 0 ]; then
loop=0
while [ "$((loop++))" -lt "6" ]
do
echo "waiting for /dev/ubi1."
if [ -e /dev/mtd1 ]; then
echo "/dev/ubi1 appear"
break
fi
/bin/sleep 1
done
else
echo "ubiattach -m 8 -d 1failed!"
exit 1
fi
非第一次操作
// umount /dav
// ubidetach /dev/ubi_ctrl -d 1
ubiattach -m 8 -d 1 /dev/ubi_ctrl //会出现/dev/ubi1节点
mount -t ubifs /dev/ubi1_0 /mnt
mount打印:
# mount -t ubifs /dev/ubi1_0 /mnt/
[ 52.943452] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 274
[ 53.387663] UBIFS (ubi1:0): recovery needed
[ 54.160605] UBIFS (ubi1:0): recovery completed
[ 54.169441] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "app_pri"
[ 54.181077] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 54.195172] UBIFS (ubi1:0): FS size: 36315136 bytes (34 MiB, 286 LEBs), journal size 1777664 bytes (1 MiB, 14 LEBs)
[ 54.209642] UBIFS (ubi1:0): reserved for root: 1715252 bytes (1675 KiB)
[ 54.219050] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID 0C991C90-92CF-4740-A810-7114851BC829, small LPT model
ubi命令用法(linux)相关推荐
- chmod命令用法(linux中chmod命令用法)
linuxsort命令有哪些用法? txt apple banana orange pear 2 sort的-u选项 它的作用很简单,就是在输出行中去除重复行. [rocrocket@rocrocke ...
- linux env命令用法,Linux env命令
可以使用env命令传递环境变量,而无需在外部环境(当前shell)上设置它们. 假设您想运行一个Node.js应用程序,并为其设置USER变量. 您可以运行: env USER=flavio node ...
- linux boot命令用法,Linux基础命令介绍 - 2
上一篇介绍了两个比较基础的两个命令: pwd cd 其实cd这个命令呢,还有一个比较常用的用法,就是: cd - 这个就是在返回最近一次使用的目录,就像电视机遥控器上的一个功能,切换到上一个节目,也就 ...
- linux mkdir命令用法,linux里面的mkdir命令
mkdir命令 [功能说明] mkdir命令是"make directories"的缩写形式,其功能是创建目录,默认情况下,如果目录已经存在,则会提示此文件已存在,而不会继续创建目 ...
- linux mkdir命令用法,linux中的mkdir命令的详细解释
linxu下的mkdir命令从字面上就可以理解其实是创建文件或者目录的意思.下面由学习啦小编为大家整理了linux的mkdir命令的详细解释的相关知识,希望对大家有帮助! 一.linux中的mkdir ...
- linux more命令用法,linux more命令详解
大家好,我是时间财富网智能客服时间君,上述问题将由我为大家进行解答. linux more命令详解分析如下: 1.使用cat命令显示install.log文件,系统会将install.log文件完整的 ...
- linux解压rz命令用法,linux压缩和解压缩命令、上传下载,rz和sz
linux压缩和解压缩命令: tar 解包:tar zxvf filename.tar 打包:tar czvf filename.tar dirname gz命令 解压1:gunzip filenam ...
- linux中ftp的用法,linux中的ftp命令用法(7页)-原创力文档
第 第 PAGE 1 页 共 NUMPAGES 1 页 linux中的ftp命令用法 Linux系统中的ftp命令功能强大,那么它的具体用法是怎样呢?下面由小编为大家整理了linux中的ftp命令用法 ...
- Linux export 命令用法
Linux export 命令用法 Linux export 命令用于设置或显示环境变量. 在 shell 中执行程序时,shell 会提供一组环境变量.export 可新增,修改或删除环境变量,供后 ...
- c语言strTrimed函数用法介绍,linux type命令用法_转
在脚本中type可用于检查命令或函数是否存在,存在返回0,表示成功:不存在返回正值,表示不成功. $ type foo >/dev/null 2>&1 || { echo > ...
最新文章
- GIT 源码管理-简介
- 动态规划和贪心算法的区别
- 架构师最怕程序员知道的十件事
- golang func 入参为func_Golang函数常见用法
- Install OpenCV-Python in Ubuntu
- 使用JPA和Spring 3.1进行事务配置
- java des对称加密_JAVA加密解密DES对称加密算法
- 现在有一个map集合如下: Map<Integer,String> map = new HashMap<Integer, String>(); map.put(1, “
- moodle分析笔记
- Ionic 4.0.2 发布,移动应用开发框架
- Android 支付宝 移动支付接口 快速配置
- JavaSE总结(适合Java期末考试复习,JavaSE部分知识回顾)
- 在layui表格中插入时间插件
- discards qualifiers —— 丢弃类型
- ArcGIS网络分析之数据组织、连通性设置
- Linux 自动挂载U盘 实现热插拔
- 求有限区间内素数个数
- 计算机桌面亮度调节,电脑屏幕亮度怎么调?笔记本屏幕亮度调节方法图解教程 电脑维修技术网...
- Zabbix主页应用介绍
- 关于ZETag云标签你了解多少?
热门文章
- Android 动画丢帧问题
- 仅仅CSS就实现了轮播图----利用关键帧动画实现轮播图效果
- 计算机学报模板百度云,《计算机学报》论文模版.
- [译] Dweb: Beaker--去中心化的浏览器 (中英)
- pip install清华镜像源
- 北京大学计算机学院复试名单2021,北京大学2021拟录取推免研究生毕业院校统计,多位来自非211高校...
- Animation动画详解
- 如何在家打造一个沉浸式的家庭影院呢?
- Updates were rejected because the tip of your current branch is behind hint: its remote counterpart
- redis源码--SDS结构解析