当前位置:网站首页>[file system] how to run squashfs on UBI
[file system] how to run squashfs on UBI
2022-07-01 06:10:00 【Ruler.】
How to be in ubi Run on squashfs
stay UBI Run on squashfs File is openwrt Common methods in the system :
- rootfs function squashfs ( read-only )
- roootfs_data function ubifs ( Reading and writing )
because ubifs Is running on the UBI File systems on volumes , and squashfs Is running on the block device File system on top of , There is no intersection between the two , however UBI Provides the ability to ubi Features of creating read-only block devices on volumes (R/O block devices on top of UBI volumes), This makes squashfs Can also “ function ” stay ubi On the roll .
R/O block devices on top of UBI volumes
UBI Allow in UBI Create a read-only block device on the volume , This volume is intended for read-only 、 Block oriented file system , for example squashfs.
UBI Allow in UBI Create a block device on the volume , But there are the following restrictions :
- read-only operation .
- Serialization I/O operation , But remember NAND The driver kernel has also serialized all I/O.
Despite these limitations , Block device for UBI It is still useful to mount a read-only regular file system on a volume . With squashfs For example , It can be used as NAND Lightweight read-only on the device rootfs. under these circumstances ,UBI Layer will handle low-level details , For example, bit reversal processing and wear equalization .
Realization principle

- Based on any MTD equipment ,attach After creating 2 individual UBI volume (volume0 and volume1)
- take squashfs Image storage volume0, take ubifs Image storage volume 1
- be based on volume0 establish ubi block device, Use this block device mount squashfs
- Use vloume 1 mount ubifs
Be careful : If you don't need to run ubifs, So just create one volume function squashfs It's OK .
demonstration
The following will demonstrate how to implement in ubi Run on squashfs:
Before doing the following , Need to know nand flash Some of the parameters . This is what I'm using nand flash Parameters of :
- block size 256KB
- page size 4KB
- (UBI)LEB 248KB
- (UBI)PEB 256KB
- flash total size 4096 blocks
- flash min I/O size 4KB
Make squashfs
Make squashfs Need to use mksquashfs Tools , For instructions, see mksquashfs
establish fs The contents are as follows :
$ ls
apps this_is_squashfs.txt
Execute the following command : according to fs directories creating squashfs, Output squashfs The image file is squashfs.img
mksquashfs fs/ squashfs.img -b 256k -nopad -noappend -root-owned -comp xz -processors 1
- -b Appoint flash One block Size
- -comp xz Specify the compression algorithm as xz
- -root-owned Of all files in the file system owner All are root
- -noappend Do not append to an existing file system
- -nopad Do not populate the file system with 4K Multiple
- -processors 1 Use 1 Processors build file systems
Make ubifs
Make squashfs Need to use mkfs.ubifs Tools , Please refer to establish UBIFS Mirror image
establish fs The contents are as follows :
$ ls
apps this_is_ubifs.txt
Execute the following command : according to fs directories creating ubifs, Output ubifs The image file is ubifs.img
mkfs.ubifs -m 4KiB -e 248KiB -c 128 --space-fixup --compr=lzo --squash-uids -r fs -o ubifs.img
Make ubi Mirror image
Make ubi Mirroring requires ubinize Tools , Reference resources ubinize Tools
in addition ,ubinize The tool also needs a description ubi Configuration file of the volume ubinize.cfg:
[my_squashfs]
mode=ubi
vol_id=0
vol_type=dynamic
vol_name=my_squashfs
image=squashfs.img
[my_ubifs]
mode=ubi
vol_id=1
vol_type=dynamic
vol_name=my_ubifs
vol_flags=autoresize
image=ubifs.img
The above configuration file contains 2 Volumes :
- Dynamic volume 0, Distribution for them ID 0 And named it
my_squashfs; The contents of the volume are taken fromsquashfs.img; - Dynamic volume 1, Distribution for them ID 1 And named it
my_ubifs; The contents of the volume are taken fromubifs.img;
my_squashfs The type of volume must be dynamic, Otherwise, it cannot be mounted later
Last , Execute the following command to generate ubi Mirror image ubi.image
ubinize -m 4KiB -p 256KiB ubinize.cfg -o ubi.image
burning ubi Mirror image
Generated in the previous step ubi.image Can write directly to flash, Use here ubiformat Tools for burning .
- burning ubi Mirror image
ubiformat /dev/mtd3 -y -f ubi.image
- attach
ubiattach -p /dev/mtd3
attach Then a new ubi Equipment and ubi volume .
Here I generate ubi2, And according to ubinize.cfg The configuration file automatically generates two volumes :my_squashfs and myubifs.
$ ubinfo -a /dev/ubi2
Volume ID: 0 (on ubi2)
Type: dynamic
Alignment: 1
Size: 1 LEBs (253952 bytes, 248.0 KiB)
State: OK
Name: my_squashfs
Character device major/minor: 506:1
-----------------------------------
Volume ID: 1 (on ubi2)
Type: dynamic
Alignment: 1
Size: 111 LEBs (28188672 bytes, 26.8 MiB)
State: OK
Name: my_ubifs
Character device major/minor: 506:2
mount
about ubifs You can mount directly , Use /dev/ubi2_1 Just mount :
mount -t ubifs /dev/ubi2_1 /test
View the files in the file system as follows :
ls /test -l
drwxrwxr-x 2 root root 224 Jun 22 14:00 app
-rw-rw-r-- 1 root root 16 Jun 22 14:00 this_is_ubifs.txt
about squashfs Further operations are needed :
- Create a read-only block device
ubiblockTools are used to create or destroy ubi Block device , How to use it is as follows :
Usage: ubiblock [-c,-r] <UBI volume node file name>
Example:
ubiblock -c /dev/ubi0_0
ubiblock -r /dev/ubi0_0
be based on ubi2_0 establish ubi The commands of the block device are as follows :
ubiblock -c /dev/ubi2_0
After execution , Will be in /dev Generate ubi Block device file
# ls /dev/ubiblock2* -l
brw------- 1 root root 252, 1 Jun 22 14:38 /dev/ubiblock2_0
Using the above block device, you can mount squashfs 了
mount -t squashfs /dev/ubiblock2_0 /test1
View the files in the file system as follows :
# ls test1/ -l
drwxrwxr-x 2 root root 30 Jun 22 10:51 apps
-rw-rw-r-- 1 root root 47 Jun 22 13:59 this_is_squashfs.txt
Check the mount information :
$ mount
/dev/ubi2_1 on /test type ubifs (rw,relatime,assert=read-only,ubi=2,vol=1)
/dev/ubiblock2_0 on /test1 type squashfs (ro,relatime)
Reference resources
边栏推荐
- OpenGL ES: (1) OpenGL ES的由来 (转)
- Through cooperation with the University of international trade, we can increase efficiency for college students
- DHT11 temperature and humidity sensor
- Why use huluer pie disk instead of U disk?
- 2022 the 8th China International "Internet +" college student innovation and entrepreneurship competition industry proposition track is open for registration!
- 机械臂速成小指南(六):步进电机驱动器
- SQL必会题之留存率
- 栈题目:解析布尔表达式
- jdbc 数据库操作
- SystemVerilog学习-06-类的封装
猜你喜欢

Arcserver password reset (account cannot be reset)

讓田頭村變甜頭村的特色農產品是仙景芋還是白菜

Pla ne colle pas sur le lit: 6 solutions simples

Fixed height of the first column in El table dynamic header rendering

Make Tiantou village sweet. Is Xianjing taro or cabbage the characteristic agricultural product of Tiantou Village

three.js小结

Timer based on LabVIEW

TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)
![kotlin位运算的坑(bytes[i] and 0xff 报错)](/img/2c/de0608c29d8af558f6f8dab4eb7fd8.png)
kotlin位运算的坑(bytes[i] and 0xff 报错)

Don't put your notes and videos everywhere!
随机推荐
π disk, turning your computer into a personal private cloud
Dear pie users, I want to confess to you!
PLA不粘貼在床上:6個簡單的解决方案
freeswitch拨打分机号
Cjc8988 Low Power Stereo codec with 2 stereo headphone drivers
Skywalking integrated Nacos dynamic configuration
让田头村变甜头村的特色农产品是仙景芋还是白菜
FPGA - 7系列 FPGA内部结构之Clocking -02- 时钟布线资源
蚂蚁新村田头村变甜头村 让厦门灌口镇田头村变甜头村的特色农产品之一是
kubeadm搭建kubenetes 集群(个人学习版)
Make: g++: command not found
Infinite horizontal marble game
论文学习记录随笔 多标签之LIFT
Database problems, how to optimize Oracle SQL query statements faster and more efficient
Chip, an empire built on sand!
El tooltip in the table realizes line breaking display
three. JS summary
可动的机械挂钟
ABP 学习解决方案中的项目以及依赖关系
Pla ne colle pas sur le lit: 6 solutions simples