当前位置:网站首页>[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++:命令未找到
- 69 cesium code datasource loading geojson
- Essay learning record essay multi label Global
- linux 关闭redis 进程 systemd+
- MySQL中 in 和 exists 的区别
- He struggled day and night to protect his data
- 3D printer threading: five simple solutions
- One of the characteristic agricultural products that make Tiantou village, Guankou Town, Xiamen into a "sweet" village is
- HDU - 1501 Zipper(记忆化深搜)
- Call us special providers of personal cloud services for College Students
猜你喜欢

Skywalking integrated Nacos dynamic configuration

three. JS summary

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

基于LabVIEW的计时器

让田头村变甜头村的特色农产品是仙景芋还是白菜

LED lighting used in health lighting

Linux closes the redis process SYSTEMd+

Crossing sect · paipan + Siyuan notes = private notebook

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

【文件系统】如何在ubi之上运行squashfs
随机推荐
It's not that you have a bad mind, but that you haven't found the right tool
Arcserver password reset (account cannot be reset)
表格中el-tooltip 实现换行展示
Excel dynamic chart
Through cooperation with the University of international trade, we can increase efficiency for college students
OpenGL es: (2) relationship between OpenGL es, EGL and glsl
Database problems, how to optimize Oracle SQL query statements faster and more efficient
HDU - 1501 Zipper(记忆化深搜)
Diffusion (multi-source search)
OpenGL ES: (1) OpenGL ES的由来 (转)
freeswitch拨打分机号
Crossing sect · paipan + Siyuan notes = private notebook
QT write custom control - self drawn battery
OpenGL es: (5) basic concepts of OpenGL, the process of OpenGL es generating pictures on the screen, and OpenGL pipeline
Enter an expression (expressed as a string) and find the value of this expression.
This is the necessary software for college students 𞓜 knowledge management
MySQL中 in 和 exists 的区别
c# Xml帮助类
Freeswitch dial the extension number
Pychart configuring jupyter