对于nand上的mtd分区,如果想要成功挂载为ubifs系统,mtd分区大小至少为5M。考虑到保留2块(256k)作为边界保护。mtd分区至少为 5120K + 256K = 5376K。
x
mtd10: 00440000 00020000 "0:XINFO"
/dev/mtd10 大小位 0x440000 = 4352k
按如下操作流程
Step1: 生成UBI设备
xxxxxxxxxx
mtd erase /dev/mtd10
ubiattach -p /dev/mtd10
xxxxxxxxxx
root@AP-:~# ubiattach -p /dev/mtd10
UBI device number 2, total 34 LEBs (4317184 bytes, 4.1 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
root@AP-:~# ubinfo /dev/ubi2
ubi2
Volumes count: 1
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 34 (4317184 bytes, 4.1 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 20
Current maximum erase counter value: 2
Minimum input/output unit size: 2048 bytes
Character device major/minor: 235:0
Present volumes: 0
Step2: 创建卷
xxxxxxxxxx
ubimkvol /dev/ubi2 -N newx -m
xxxxxxxxxx
root@AP-:~# ubinfo /dev/ubi2_0
Volume ID: 0 (on ubi2)
Type: dynamic
Alignment: 1
Size: 10 LEBs (1269760 bytes, 1.2 MiB)
State: OK
Name: newx
Character device major/minor: 235:1
Step3: 挂载卷
x
mkdir /tmp/xxx
mount -t ubifs /dev/ubi2_0 /tmp/xxx/
挂载失败的错误原因分析
root@AP-:~# mount -t ubifs /dev/ubi2_0 /tmp/xxx/
mount: wrong fs type, bad option, bad superblock on /dev/ubi2_0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
root@AP-:~# dmesg | tail -n 3
[ 1821.308864] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" stops
[ 1849.640137] UBIFS error (ubi2:0 pid 26396): init_constants_early: too few LEBs (10), min. is 17
[ 1907.159879] UBIFS error (ubi2:0 pid 27961): init_constants_early: too few LEBs (10), min. is 17
=> 即至少需要 17 个LEB 才能挂载。
分区大小
x
mtd10: 00540000 00020000 "0:XINFO"
/dev/mtd10 大小位 0x540000 = 5376k
Step1: 生成UBI设备
xxxxxxxxxx
mtd erase /dev/mtd10
ubiattach -p /dev/mtd10
xxxxxxxxxx
root@AP-:~# ubiattach -p /dev/mtd10
UBI device number 2, total 42 LEBs (5332992 bytes, 5.1 MiB), available 18 LEBs (2285568 bytes, 2.2 MiB), LEB size 126976 bytes (124.0 KiB)
Step2: 创建卷
xxxxxxxxxx
ubimkvol /dev/ubi2 -N newx -m
xxxxxxxxxx
root@AP-:~# ubimkvol /dev/ubi2 -N newx -m
Set volume size to 2285568
Volume ID 0, size 18 LEBs (2285568 bytes, 2.2 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "newx", alignment 1
root@AP-:~# ubinfo /dev/ubi2_0
Volume ID: 0 (on ubi2)
Type: dynamic
Alignment: 1
Size: 18 LEBs (2285568 bytes, 2.2 MiB)
State: OK
Name: newx
Character device major/minor: 235:1
Step3: 挂载卷
xxxxxxxxxx
mkdir /tmp/xxx
mount -t ubifs /dev/ubi2_0 /tmp/xxx/
x
root@AP-:/tmp/xxx# df -h
Filesystem Size Used Available Use% Mounted on
/dev/ubi2_0 456.0K 20.0K 376.0K 5% /tmp/xxx
root@AP-:~# mount
/dev/ubi2_0 on /tmp/xxx type ubifs (rw,relatime)