Reference
Environment
~ >: uname -a
Linux localhost 3.0.0 #205 Wed Dec 7 16:47:04 CST 2011 armv5tejl GNU/Linux
~ >:
~ >: cat /proc/cpuinfo
Processor : ARM926EJ-S rev 5 (v5l)
BogoMIPS : 98.71
Features : swp half fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part : 0x926
CPU revision : 5
Hardware : Atmel AT91SAM9260-EK
Revision : 0000
Serial : 0000000000000000
~ >:
~ >: cat /proc/meminfo | grep "MemTotal"
MemTotal: 61888 kB
~ >:
Requiresment
~ >: cat /proc/filesystems
nodev ubifs # Make sure u can see this line in file /proc/filesystems
Create steps
ubiattach /dev/ubi_ctrl -m 9 # means attach mtd block 9 as UBI, after this CMD will cread /dev/ubi0
ubimkvol /dev/ubi0 -N rootfs -s 51351500 # create volumes on the UBI device /dev/ubi0 with size 48MiB about
mount -o sync,noatime -t ubifs /dev/ubi0_0 /data/ # mount this volume
Destory steps
umount /data
ubirmvol /dev/ubi0 -n 0
ubidetach -d 0 /dev/ubi_ctrl
Operation on My board atmel at91sam9260
~ >: cat /proc/filesystems | grep "ubifs"
nodev ubifs
~ >:
~ >: ls /dev/ubi*
/dev/ubi_ctrl
~ >:
~ >: cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00020000 "bootloader------256KB"
mtd1: 00020000 00020000 "boot ENV--------128KB"
mtd2: 00020000 00020000 "boot ENV BAK----128KB"
mtd3: 00500000 00020000 "linux kernel----5MB"
mtd4: 00a00000 00020000 "filesystem------10MB"
mtd5: 00500000 00020000 "backup_kernel---5MB"
mtd6: 01400000 00020000 "backup_fs-------20MB"
mtd7: 01e00000 00020000 "apps------------30MB"
mtd8: 00500000 00020000 "info------------5MB"
mtd9: 03300000 00020000 "data------------51M"
~ >:
~ >: ubiattach /dev/ubi_ctrl -m 9
[ 648.660000] UBI: attaching mtd9 to ubi0
[ 648.670000] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 648.670000] UBI: logical eraseblock size: 129024 bytes
[ 648.680000] UBI: smallest flash I/O unit: 2048
[ 648.680000] UBI: sub-page size: 512
[ 648.690000] UBI: VID header offset: 512 (aligned 512)
[ 648.690000] UBI: data offset: 2048
[ 648.780000] UBI: max. sequence number: 126
[ 648.800000] UBI: attached mtd9 to ubi0
[ 648.810000] UBI: MTD device name: "data------------51M"
[ 648.810000] UBI: MTD device size: 51 MiB
[ 648.820000] UBI: number of good PEBs: 406
[ 648.820000] UBI: number of bad PEBs: 2
[ 648.830000] UBI: number of corrupted PEBs: 0
[ 648.830000] UBI: max. allowed volumes: 128
[ 648.830000] UBI: wear-leveling threshold: 4096
[ 648.840000] UBI: number of internal volumes: 1
[ 648.840000] UBI: number of user volumes: 0
[ 648.850000] UBI: available PEBs: 398
[ 648.850000] UBI: total number of reserved PEBs: 8
[ 648.860000] UBI: number of PEBs reserved for bad PEB handling: 4
[ 648.860000] UBI: max/mean erase counter: 22/1
[ 648.870000] UBI: image sequence number: 1434265609
[ 648.880000] UBI: background thread "ubi_bgt0d" started, PID 494
~ >:
~ >:
~ >: ubimkvol /dev/ubi0 -N rootfs -s 51351500
~ >:
~ >: mount -o sync,noatime -t ubifs /dev/ubi0_0 /data/ # mount this volume
[ 663.200000] UBIFS: default file-system created
[ 663.270000] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[ 663.270000] UBIFS: file system size: 50190336 bytes (49014 KiB, 47 MiB, 389 LEBs)
[ 663.280000] UBIFS: journal size: 2451456 bytes (2394 KiB, 2 MiB, 19 LEBs)
[ 663.290000] UBIFS: media format: w4/r0 (latest is w4/r0)
[ 663.290000] UBIFS: default compressor: lzo
[ 663.300000] UBIFS: reserved for root: 2370612 bytes (2315 KiB)
~ >:
~ >: mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw,relatime,errors=continue)
proc on /proc type proc (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)
/dev/mtdblock6 on /apps type jffs2 (ro,sync,noatime)
/dev/mtdblock7 on /info type jffs2 (ro,sync,noatime)
/dev/ubi0_0 on /data type ubifs (rw,sync,noatime)
~ >:
~ >: df -h
Filesystem Size Used Available Use% Mounted on
rootfs 9.7M 4.4M 5.2M 46% /
/dev/root 9.7M 4.4M 5.2M 46% /
tmpfs 30.2M 0 30.2M 0% /dev
/dev/mtdblock6 20.0M 1.3M 18.7M 6% /apps
/dev/mtdblock7 30.0M 1.1M 28.9M 4% /info
/dev/ubi0_0 44.3M 20.0K 42.0M 0% /data
~ >:
~ >:
~ >:
~ >:
~ >: umount /data
[ 668.970000] UBIFS: un-mount UBI device 0, volume 0
~ >:
~ >: ubirmvol /dev/ubi0 -n 0
~ >:
~ >: ubidetach -d 0 /dev/ubi_ctrl
[ 677.010000] UBI: mtd9 is detached from ubi0
~ >: