1.ubi命令
ubifs常见命令
flash_erase /dev/mtdx 0 0 擦除
ubiformat /dev/mtdx 格式化磁盘
ubiattach /dev/ubi_ctrl -m x 添加分区
ubimkvol /dev/ubi0 -Nrootfs -m
ubimkvol /dev/ubi0 -Nrootfs -s xxxxKiB
ubimkvol /dev/ubi0 -Ndatafs -s xxxxKiB
mount -t ubifs ubi0:rootfs /xxxxx
mount -t ubifs ubi0:datafs /xxxx
2.问题以及解决方案
[root@xxxx /]#ubiattach /dev/ubi_ctrl -m 8
UBI error: ubi_read_volume_table: the layout volume was not found
UBI error: ubi_attach_mtd_dev: failed to attach mtd8, error -22
ubiattach: error!: cannot attach mtd8
error 22 (Invalid argument)
上面报错是因为/dev/mtd8分区没有格式化,所以需要如下操作
[root@xxxx /]#ubiformat /dev/mtd8
ubiformat: mtd8 (nand), size 822083584 bytes (784.0 MiB), 6272 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 6271 -- 100 % complete
ubiformat: 4523 eraseblocks have valid erase counter, mean value is 1
ubiformat: 1731 eraseblocks are supposedly empty
ubiformat: 18 bad eraseblocks found, numbers: 274, 275, 328, 329, 810, 811, 1360, 1361, 1490, 1491, 2074, 2075, 2114, 2115, 6268, 6269, 6270, 6271
ubiformat: warning!: only 4523 of 6254 eraseblocks have valid erase counter
ubiformat: mean erase counter 1 will be used for the rest of eraseblock
ubiformat: continue? (y/N) y
ubiformat: use erase counter 1 for all eraseblocks
ubiformat: formatting eraseblock 6271 -- 100 % complete
或者对/dev/mtd8分区进行擦除操作
[root@xxxx /]#flash_eraseall /dev/mtd8
Erasing 128 Kibyte @ 2220000 - 4% complete.
Skipping bad block at 0x02240000
Skipping bad block at 0x02260000
Erasing 128 Kibyte @ 28e0000 - 5% complete.
Skipping bad block at 0x02900000
Skipping bad block at 0x02920000
Erasing 128 Kibyte @ 6520000 - 12% complete.
Skipping bad block at 0x06540000
Skipping bad block at 0x06560000
Erasing 128 Kibyte @ a9e0000 - 21% complete.
Skipping bad block at 0x0aa00000
Skipping bad block at 0x0aa20000
Erasing 128 Kibyte @ ba20000 - 23% complete.
Skipping bad block at 0x0ba40000
Skipping bad block at 0x0ba60000
Erasing 128 Kibyte @ 10320000 - 33% complete.
Skipping bad block at 0x10340000
Skipping bad block at 0x10360000
Erasing 128 Kibyte @ 10820000 - 33% complete.
Skipping bad block at 0x10840000
Skipping bad block at 0x10860000
Erasing 128 Kibyte @ 30f60000 - 99% complete.
Skipping bad block at 0x30f80000
Skipping bad block at 0x30fa0000
Skipping bad block at 0x30fc0000
Skipping bad block at 0x30fe0000
Erasing 128 Kibyte @ 31000000 - 100% complete.
针对ubiattach和flash_eraseall命令操作/dev/mtd8 容量为784M,前者耗时59秒、后者耗时25秒,从生产效益上选择flash_eraseall命令。
再次添加分区,执行成功
[root@xxxx /]#ubiattach /dev/ubi_ctrl -m 8
UBI device number 0, total 6254 LEBs (794107904 bytes, 757.3 MiB), available 6106 LEBs (775315456 bytes, 739.4 MiB), LEB size 126976 bytes (124.0 KiB)
[
创建卷
[root@xxxx /]#ubimkvol -m /dev/ubi0 -N my-ubifs
Set volume size to 775315456
Volume ID 0, size 6106 LEBs (775315456 bytes, 739.4 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "my-ubifs", alignment 1
挂载
[root@xxxx /]#mkdir /mnt/ubifs
[root@xxxx /]#mount -t ubifs -o sync,noatime ubi0_0 /mnt/ubifs
[root@xxxx /]#mount
rootfs on / type rootfs (rw)
/dev/root on / type cramfs (ro,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=29636k,nr_inodes=7409,mode=755)
proc on /proc type proc (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,relatime,mode=777)
tmpfs on /tmp type tmpfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
sysfs on /sys type sysfs (rw,relatime)
ramfs on /mnt type ramfs (rw,relatime)
ramfs on /etc type ramfs (rw,relatime)
ramfs on /clou type ramfs (rw,relatime)
ramfs on /home type ramfs (rw,relatime)
ramfs on /var/empty type ramfs (rw,relatime)
/dev/mtdblock5 on /mnt/app type yaffs2 (rw,relatime)
/dev/mtdblock6 on /mnt/ext type yaffs2 (rw,relatime)
ubi0_0 on /mnt/ubifs type ubifs (rw,sync,noatime)
挂载成功:ubi0_0 on /mnt/ubifs type ubifs (rw,sync,noatime)