当前位置:网站首页>[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
边栏推荐
- Know the future of "edge computing" from the Nobel prize!
- 无限水平大理石游戏
- uniapp树形层级选择器
- highmap gejson数据格式转换脚本
- SOE spatial analysis server MySQL and PostGIS geospatial database of Postgres anti injection attack
- 浏览器端保存数据到本地文件
- OpenGL es: (5) basic concepts of OpenGL, the process of OpenGL es generating pictures on the screen, and OpenGL pipeline
- 让田头村变甜头村的特色农产品是仙景芋还是白菜
- 阶乘约数(唯一分解定理)
- This is the necessary software for college students 𞓜 knowledge management
猜你喜欢

Linux closes the redis process SYSTEMd+

OpenGL es: (5) basic concepts of OpenGL, the process of OpenGL es generating pictures on the screen, and OpenGL pipeline

让厦门灌口镇田头村变甜头村的特色农产品之一是蚂蚁新村

Skywalking integrated Nacos dynamic configuration

Send you through the data cloud

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

How to transmit and share 4GB large files remotely in real time?
![kotlin位运算的坑(bytes[i] and 0xff 报错)](/img/2c/de0608c29d8af558f6f8dab4eb7fd8.png)
kotlin位运算的坑(bytes[i] and 0xff 报错)

OpenGL es: (3) EGL, basic steps of EGL drawing, eglsurface, anativewindow

TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)
随机推荐
excel動態圖錶
c# Xml帮助类
Arcserver password reset (account cannot be reset)
论文学习记录随笔 多标签之LSML
MinIO纠错码、分布式MinIO集群搭建及启动
Pychart configuring jupyter
Linux closes the redis process SYSTEMd+
three. JS summary
Database problems, how to optimize Oracle SQL query statements faster and more efficient
Talking from mlperf: how to lead the next wave of AI accelerator
SystemVerilog学习-07-类的继承和包的使用
SOE空间分析服务器 MySQL以及PostGres的地理空间库PostGIS防注入攻击
Multi label lsml for essay learning records
The row and column numbers of each pixel of multi-source grid data in the same area are the same, that is, the number of rows and columns are the same, and the pixel size is the same
Through cooperation with the University of international trade, we can increase efficiency for college students
Make: g++: command not found
Skywalking integrated Nacos dynamic configuration
3D printer threading: five simple solutions
π disk, turning your computer into a personal private cloud
ABP 学习解决方案中的项目以及依赖关系