当前位置:网站首页>[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
边栏推荐
- Make: g++: command not found
- ArcServer密码重置(账号不可以重置)
- Index method and random forest to realize the information of surface water body in wet season in Shandong Province
- C# ManualResetEvent 类的理解
- 分布式锁实现
- How does MySQL store Emoji?
- 指数法和Random Forest实现山东省丰水期地表水体信息
- Stack Title: parsing Boolean expressions
- 相同区域 多源栅格数据 各个像元行列号一致,即行数列数相同,像元大小相同
- 68 cesium code datasource loading czml
猜你喜欢

解决麒麟V10上传文件乱码问题

论文学习记录随笔 多标签之GLOCAL

Cjc8988 Low Power Stereo codec with 2 stereo headphone drivers

数据库问题,如何优化Oracle SQL查询语句更快,效率更高

Excel dynamic chart

TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)

Thesis learning record essay multi label lift

C language beginner level - realize the minesweeping game

69 cesium code datasource loading geojson

2022 年面向初学者的 10 大免费 3D 建模软件
随机推荐
My experience from technology to product manager
Flink实战--多流合并
Chip, an empire built on sand!
Make: g++: command not found
2022 年面向初学者的 10 大免费 3D 建模软件
srpingboot security demo
PLA不粘贴在床上:6个简单的解决方案
Cjc8988 Low Power Stereo codec with 2 stereo headphone drivers
C# ManualResetEvent 类的理解
Oracle sequence + trigger
Servlet
Leetcode Max rectangle, Max square series 84 85. 221. 1277. 1725. (monotonic stack, dynamic programming)
What if the data in the cloud disk is harmonious?
PLA不粘貼在床上:6個簡單的解决方案
无限水平大理石游戏
excel動態圖錶
论文学习记录随笔 多标签之LSML
Scope data export mat
skywalking集成nacos动态配置
He struggled day and night to protect his data