平台:AT91SAM9G25EK
整个nand mtd分区分了3部分分别为mtd0 mtd1 mtd2
mtd0 | 存放kernel uboot bstrap |
mtd1 | ubifs ubi volume 1 |
mtd2 | ubi volume 1 |
[ 2.489000] UBI: attaching mtd2 to ubi1 [ 2.493000] UBI: physical eraseblock size: 131072 bytes (128 KiB) [ 2.499000] UBI: logical eraseblock size: 126976 bytes [ 2.504000] UBI: smallest flash I/O unit: 2048 [ 2.509000] UBI: VID header offset: 2048 (aligned 2048) [ 2.515000] UBI: data offset: 4096 [ 2.786000] UBI: max. sequence number: 34 [ 2.806000] UBI: attached mtd2 to ubi1 [ 2.809000] UBI: MTD device name: "usrdata" [ 2.815000] UBI: MTD device size: 91 MiB [ 2.819000] UBI: number of good PEBs: 728 [ 2.824000] UBI: number of bad PEBs: 0 [ 2.828000] UBI: number of corrupted PEBs: 0 [ 2.833000] UBI: max. allowed volumes: 128 [ 2.837000] UBI: wear-leveling threshold: 4096 [ 2.842000] UBI: number of internal volumes: 1 [ 2.846000] UBI: number of user volumes: 1 [ 2.851000] UBI: available PEBs: 56 [ 2.855000] UBI: total number of reserved PEBs: 672 [ 2.860000] UBI: number of PEBs reserved for bad PEB handling: 7 [ 2.866000] UBI: max/mean erase counter: 2/1 [ 2.870000] UBI: image sequence number: -661745834 [ 2.875000] UBI: background thread "ubi_bgt1d" started, PID 465 [ 2.913000] <span style="color:#ff0000;">UBI error: ubi_create_volume: cannot create volume 1, error -28 ubimkvol: UBI_IOCMKVOL: No space left on device</span> [ 2.995000] UBIFS: mounted UBI device 1, volume 0, name "appdata" [ 3.001000] UBIFS: file system size: 82661376 bytes (80724 KiB, 78 MiB, 651 LEBs) [ 3.009000] UBIFS: journal size: 4190208 bytes (4092 KiB, 3 MiB, 33 LEBs) [ 3.016000] UBIFS: media format: w4/r0 (latest is w4/r0) [ 3.022000] UBIFS: default compressor: lzo [ 3.026000] UBIFS: reserved for root: 3904300 bytes (3812 KiB)
文件系统挂载后,将mtd2格式化ubi volume并挂载,结果发现挂载失败,提示空间不足《ubimkvol: UBI_IOCMKVOL: No space left on device》,error=-28
挺奇怪的。因为,整个分区90M大小,啥东西没有。
df查看,mnt/data也已经挂载。原因究竟为何??创建了一个4M大小的文件后,df显示如下,感觉挺正常的。
[root@(none) /]# df Filesystem 1K-blocks Used Available Use% Mounted on ubi0:rootfs 26836 2240 24596 8% / devtmpfs 62648 0 62648 0% /dev ubi1_0 73972 4424 65736 6% /mnt/data从打印入手吧。
整个格式化mtd2为ubi系统类型的分区步骤有3个
首先attach 然后 make volume,最后 mount,rcS的启动脚本相关的三行命令如下
#attach mtd2 to be ubi volume ubiattach /dev/ubi_ctrl -m 2 #make ubi1 size=80MiB dynamic ubimkvol /dev/ubi1 -N usrdata -s 83886080 -t dynamic #mount ubit ---> /mnt/data mount -t ubifs ubi1_0 /mnt/data对打印信息提示的错误来说,问题出现在第二步ubimkvol上,下面截取上面打印的一部分进行分析
[ 2.809000] UBI: MTD device name: "usrdata"<span style="white-space:pre"> </span>//是准备创建一个命名为usrdata的ubi vol,没错!! [ 2.815000] UBI: MTD device size: 91 MiB<span style="white-space:pre"> </span>//隶属的mtd分区大小 没错 [ 2.819000] UBI: number of good PEBs: 728 //728 ÷ 8 = 91MiB 没错 [ 2.824000] UBI: number of bad PEBs: 0 //没坏块 差不多 [ 2.828000] UBI: number of corrupted PEBs: 0//掉电 数据损坏的块,没有,正常 [ 2.833000] UBI: max. allowed volumes: 128//最大允许的vol数量 [ 2.837000] UBI: wear-leveling threshold: 4096//损耗阀值 [ 2.842000] UBI: number of internal volumes: 1// [ 2.846000] UBI: number of user volumes: 1 [ 2.851000] UBI: available PEBs: 56//该mtd只能获取56个,什么情况!!!!???明明该分区啥玩意没有啊! [ 2.855000] UBI: total number of reserved PEBs: 672//保留了672
重新reboot在uboot里用nand erase 把mtd2擦除下就OK
擦除后,重新启动后的打印信息如下:
[ 2.486000] UBI: attaching mtd2 to ubi1 [ 2.490000] UBI: physical eraseblock size: 131072 bytes (128 KiB) [ 2.496000] UBI: logical eraseblock size: 126976 bytes [ 2.502000] UBI: smallest flash I/O unit: 2048 [ 2.506000] UBI: VID header offset: 2048 (aligned 2048) [ 2.512000] UBI: data offset: 4096 [ 2.650000] UBI: empty MTD device detected [ 2.654000] UBI: max. sequence number: 0 [ 2.659000] UBI: create volume table (copy #1) [ 2.668000] UBI: create volume table (copy #2) [ 2.682000] UBI: attached mtd2 to ubi1 [ 2.685000] UBI: MTD device name: "usrdata" [ 2.691000] UBI: MTD device size: 91 MiB [ 2.695000] UBI: number of good PEBs: 728 [ 2.700000] UBI: number of bad PEBs: 0 [ 2.704000] UBI: number of corrupted PEBs: 0 [ 2.709000] UBI: max. allowed volumes: 128 [ 2.713000] UBI: wear-leveling threshold: 4096 [ 2.718000] UBI: number of internal volumes: 1 [ 2.722000] UBI: number of user volumes: 0 [ 2.727000] UBI: available PEBs: 717 [ 2.731000] UBI: total number of reserved PEBs: 11 [ 2.736000] UBI: number of PEBs reserved for bad PEB handling: 7 [ 2.742000] UBI: max/mean erase counter: 0/0 [ 2.746000] UBI: image sequence number: 1705172159 [ 2.751000] UBI: background thread "ubi_bgt1d" started, PID 464 [ 3.248000] UBIFS: default file-system created [ 3.290000] UBIFS: mounted UBI device 1, volume 0, name "usrdata" [ 3.296000] UBIFS: file system size: 72376320 bytes (70680 KiB, 69 MiB, 570 LEBs) [ 3.304000] UBIFS: journal size: 3555328 bytes (3472 KiB, 3 MiB, 28 LEBs) [ 3.311000] UBIFS: media format: w4/r0 (latest is w4/r0) [ 3.317000] UBIFS: default compressor: lzo [ 3.321000] UBIFS: reserved for root: 3418512 bytes (3338 KiB)