Last time, we made jffs2 file system and realized the mount of jffs2 in common partition. This time, we also realized the mount of ubifs file system. You can try the mount of common partition in ubifs.
Nandflash partition
MTD equipment zoning
~ >: cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "mtdblock0 u-boot 1MB"
mtd1: 00f00000 00020000 "mtdblock1 kernel 15MB"
mtd2: 02800000 00020000 "mtdblock2 rootfs 40MB"
mtd3: 05000000 00020000 "mtdblock3 apps 80MB"
mtd4: 05000000 00020000 "mtdblock4 data 80MB"
mtd5: 02800000 00020000 "mtdblock5 backup 40MB"
linux kernel partition
~ >: cat /proc/partitions
major minor #blocks name
31 0 1024 mtdblock0
31 1 15360 mtdblock1
31 2 40960 mtdblock2
31 3 81920 mtdblock3
31 4 81920 mtdblock4
31 5 40960 mtdblock5
Block device corresponding to partition
~ >: ls -l /dev/mtdblock*
brw-rw---- 1 root root 31, 0 Jan 1 00:00 /dev/mtdblock0
brw-rw---- 1 root root 31, 1 Jan 1 00:00 /dev/mtdblock1
brw-rw---- 1 root root 31, 2 Jan 1 00:00 /dev/mtdblock2
brw-rw---- 1 root root 31, 3 Jan 1 00:00 /dev/mtdblock3
brw-rw---- 1 root root 31, 4 Jan 1 00:00 /dev/mtdblock4
brw-rw---- 1 root root 31, 5 Jan 1 00:00 /dev/mtdblock5
Building UBI volume
Take mtdblock3 as an example, and mount it to the / apps mount point in the format of ubifs file
Erase corresponding partition
~ >: flash_eraseall /dev/mtd3
Erasing 128 Kibyte @ 5000000 - 100% complete.
Current device
~ >: ls /dev/ubi*
/dev/ubi0 /dev/ubi0_0 /dev/ubi_ctrl
~ >: ubiattach
BusyBox v1.27.1 (2018-04-03 02:25:34 PDT) multi-call binary.
Usage: ubiattach -m MTD_NUM [-d UBI_NUM] [-O VID_HDR_OFF] UBI_CTRL_DEV
Attach MTD device to UBI
-m MTD_NUM MTD device number to attach
-d UBI_NUM UBI device number to assign
-O VID_HDR_OFF VID header offset
~ >:
Establishing correlation
~ >: ubiattach -m 3 -d 3 /dev/ubi_ctrl
UBI: attaching mtd3 to ubi3
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 129024 bytes
UBI: smallest flash I/O unit: 2048
UBI: sub-page size: 512
UBI: VID header offset: 512 (aligned 512)
UBI: data offset: 2048
UBI: empty MTD device detected
UBI: max. sequence number: 0
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd3 to ubi3
UBI: MTD device name: "mtdblock3 apps 80MB"
UBI: MTD device size: 80 MiB
UBI: number of good PEBs: 640
UBI: number of bad PEBs: 0
UBI: number of corrupted PEBs: 0
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 0
UBI: available PEBs: 630
UBI: total number of reserved PEBs: 10
UBI: number of PEBs reserved for bad PEB handling: 6
UBI: max/mean erase counter: 0/0
UBI: image sequence number: 759054630
UBI: background thread "ubi_bgt3d" started, PID 972
~ >: ls /dev/ubi*
/dev/ubi0 /dev/ubi0_0 /dev/ubi3 /dev/ubi_ctrl
~ >:
Building UBI volume
~ >: ubimkvol -m -n 0 -N apps /dev/ubi3
~ >: ls /dev/ubi*
/dev/ubi0 /dev/ubi0_0 /dev/ubi3 /dev/ubi3_0 /dev/ubi_ctrl
~ >: ubimkvol
BusyBox v1.27.1 (2018-04-03 02:25:34 PDT) multi-call binary.
Usage: ubimkvol -N NAME [-s SIZE | -m] UBI_DEVICE
Create UBI volume
-a ALIGNMENT Volume alignment (default 1)
-m Set volume size to maximum available
-n VOLID Volume ID. If not specified,
assigned automatically
-N NAME Volume name
-s SIZE Size in bytes
-t TYPE Volume type (static|dynamic)
~ >:
File system mount
Mount ubi3 (mtdblock3) to the / apps mount point
~ >: mount -t ubifs -o sync,noatime,rw ubi3:apps /apps/
UBIFS: default file-system created
UBIFS: mounted UBI device 3, volume 0, name "apps"
UBIFS: file system size: 80123904 bytes (78246 KiB, 76 MiB, 621 LEBs)
UBIFS: journal size: 3999744 bytes (3906 KiB, 3 MiB, 31 LEBs)
UBIFS: media format: w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root: 3784449 bytes (3695 KiB)
~ >: mount
rootfs on / type rootfs (rw)
ubi0:rootfs on / type ubifs (rw,relatime)
proc on /proc type proc (rw,relatime)
usbfs on /proc/bus/usb type usbfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
ramfs on /tmp type ramfs (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
ubi3:apps on /apps type ubifs (rw,sync,noatime)
Unloading and reloading
Uninstall disassociate
~ >: umount /apps/
UBIFS: un-mount UBI device 3, volume 0
~ >: ubidetach -d 3 /dev/ubi_ctrl
UBI: mtd3 is detached from ubi3
~ >: ls /dev/ubi*
/dev/ubi0 /dev/ubi0_0 /dev/ubi_ctrl
Reestablishing relationships
~ >: ubiattach -m 3 -d 3 /dev/ubi_ctrl
UBI: attaching mtd3 to ubi3
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 129024 bytes
UBI: smallest flash I/O unit: 2048
UBI: sub-page size: 512
UBI: VID header offset: 512 (aligned 512)
UBI: data offset: 2048
UBI: max. sequence number: 12
UBI: attached mtd3 to ubi3
UBI: MTD device name: "mtdblock3 apps 80MB"
UBI: MTD device size: 80 MiB
UBI: number of good PEBs: 640
UBI: number of bad PEBs: 0
UBI: number of corrupted PEBs: 0
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 1
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 640
UBI: number of PEBs reserved for bad PEB handling: 6
UBI: max/mean erase counter: 2/1
UBI: image sequence number: 759054630
UBI: background thread "ubi_bgt3d" started, PID 992
~ >: ls /dev/ubi*
/dev/ubi0 /dev/ubi0_0 /dev/ubi3 /dev/ubi3_0 /dev/ubi_ctrl
Relevancy question again
~ >: ubimkvol -m -n 0 -N apps /dev/ubi3
ubimkvol: UBI_IOCMKVOL: Invalid argument
When associating ubi3 to mtd3 again, an error was found in creating the UBI volume again. This also means that if the partition of the UBI volume that has been previously established with ubimkvol is mounted again, you do not need to execute this command, that is to say, ubimkvol can only do it once for a partition, unless you reformat it with flash \ eraseal.