UBIFS is next generation of JFFS2 file-system.
JFFS2 file systems works on MTD devices, UBIFS is works on UBI volumes which is on MTD devices.
UBIFS is much more quicker than JFFS2 and nowadays people prefer UBI as filesystem.
For more information on MTD, refer <http://www.linux-mtd.infradead.org/doc/general.html> ,on UBI refer <http://www.linux-mtd.infradead.org/doc/ubi.html> ,on UBIFS refer <http://www.linux-mtd.infradead.org/doc/ubifs.html>
Most used UBIFS User-space tools are shown below.All All UBI tools support "-h" option and print sufficient usage information.You can use "-h" option to see help about commands.
ubinfo - provides information about UBI devices and volumes found in the system; ubiattach - attaches MTD devices (which describe raw flash) to UBI and creates corresponding UBI devices; ubidetach - detaches MTD devices from UBI devices (the opposite to what ubiattach does); ubimkvol - creates UBI volumes on UBI devices; ubirmvol - removes UBI volumes from UBI devices; ubiupdatevol - updates UBI volumes; this tool uses the UBI volume update feature which leaves the volume in "corrupted" state if the update was interrupted; additionally, this tool may be used to wipe out UBI volumes; ubicrc32 - calculates CRC-32 checksum of a file with the same initial seed as UBI would use; ubinize - generates UBI images; ubiformat - formats empty flash, erases flash and preserves erase counters, flashes UBI images to MTD devices; mtdinfo - reports information about MTD devices found in the system.
To enable UBIFS, you should make some configuration.You can see them below.
Start the Linux Kernel Configuration
$ make ARCH=arm CROSS-COMPILE=arm-none-linux-gnueabi- menuconfig
Firstly you should enable UBI block images.
Select following options in menuconfig.
... ... Power management options ---> [ ] Networking support ---> Device Drivers ---> ...
... ... < > Connector - unified userspace <-> kernelspace linker ---> <*> Memory Technology Device (MTD) support ---> < > Parallel port support ---> ...
... <*> Enable UBI - Unsorted block images --->
Enable UBI as a filesystem.
Select following options in menuconfig.
... ... Device Drivers ---> File systems ---> ...
... ... Pseudo filesystems ---> [*] Miscellaneous filesystems ---> [*] Network File Systems ---> ...
... ... <*> UBIFS file system support [*] Extended attributes support [*] Advanced compression options [ ] Enable debugging support ...
The MTD and UBI user-space tools are available from the the following git repository:
git://git.infradead.org/mtd-utils.git
However,we suggest you to download our pre-built mtd-utils at here
From information on how to create a UBIFS image. refer create an UBIFS image
Boot from NFS.
You can use following command to learn parameter which is necessary for UBIFS creation.
root@bosphorus-1:/# ./sbin_mtd/mtdinfo /dev/mtd5 -u mtd5 Name: filesystem2 Type: nand Eraseblock size: 131072 bytes, 128.0 KiB Amount of eraseblocks: 976 (127926272 bytes, 122.0 MiB) Minimum input/output unit size: 2048 bytes Sub-page size: 512 bytes OOB size: 64 bytes Character device major/minor: 90:10 Bad blocks are allowed: true Device is writable: true Default UBI VID header offset: 512 Default UBI data offset: 2048 Default UBI LEB size: 129024 bytes, 126.0 KiB Maximum UBI volumes count: 128 root@bosphorus-1:/#
There are two steps for creating UBIFS.First,
mkfs.ubifs
General use of mkfs.ubifs,
# mkfs.ubifs -r </path/to/your/rootfs/tree> -m <min io size> -e <LEB size> -c <Eraseblocks count> -o </path/to/output/ubifs.img>
For Bosphorus-I,
mtd-utils# mkfs.ubifs/mkfs.ubifs -r filesystem/ -F -o ubifs.img -m 2048 -e 126976 -c 1580
The output of the above command, ubifs.img is fed into the 'ubinize' program to wrap it into a UBI image.
The images produced by mkfs.ubifs must be further fed to the ubinize tool to create a UBI image which must be put to the raw flash to be used a UBI partition.
Second step,
Create ubinize.cfg file and write the contents into it
mtd-utils# vi ubinize.cfg [ubifs] <== Section header mode=ubi <== Volume mode (other option is static) image=ubifs.img <== Source image vol_id=0 <== Volume ID in UBI image vol_size=122MiB <== Volume size vol_type=dynamic <== Allow for dynamic resize vol_name=rootfs <== Volume name vol_flags=autoresize <== Autoresize volume at first mount
ubinize
General use of ubinize,
ubinize -o <output image> -m <min io size> -p <PEB size>KiB <configuration file>
For Bosphorus-I,
./sbin_mtd/ubinize -o ubi.img -m 2048 -p 128KiB -s 2048 -O 2048 ubinize.cfg
For more information about parameter you can use "-h" option.
Where:
-o ubi.img
Output file
-m 2KiB (or 2048)
Minimum flash I/O size of 2KiB page
-p 128KiB
Size of the physical eraseblock of the flash this UBI image is created for
-O 2048 offset if the VID header from start of the physical eraseblock
The output of the above command, 'ubi.img' is the required image.
Yo can use following command to flash UBIFS.
root@bosphorus-1:/# ./sbin_mtd/ubiformat /dev/mtd5 -f ubi.img -s 2048 -O 2048 ubiformat: mtd5 (nand), size 127926272 bytes (122.0 MiB), 976 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes libscan: scanning eraseblock 975 -- 100 % complete ubiformat: 972 eraseblocks have valid erase counter, mean value is 6 ubiformat: 4 bad eraseblocks found, numbers: 972, 973, 974, 975 ubiformat: flashing eraseblock 131 -- 100 % complete ubiformat: formatting eraseblock 975 -- 100 % complete root@bosphorus-1:/#
Attaching UBIFS, you can use following command.If you want to mount UBIFS, firstly you should attach it.You can use ubidetach for detaching.
root@bosphorus-1:/# ./sbin_mtd/ubiattach --vid-hdr-offset 2048 /dev/ubi_ctrl -m5 UBI: attaching mtd5 to ubi0 UBI: physical eraseblock size: 131072 bytes (128 KiB) UBI: logical eraseblock size: 126976 bytes UBI: smallest flash I/O unit: 2048 UBI: sub-page size: 512 UBI: VID header offset: 2048 (aligned 2048) UBI: data offset: 4096 UBI: max. sequence number: 0 UBI: volume 0 ("rootfs") re-sized from 826 to 959 LEBs UBI: attached mtd5 to ubi0 UBI: MTD device name: "filesystem2" UBI: MTD device size: 122 MiB UBI: number of good PEBs: 972 UBI: number of bad PEBs: 4 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: 972 UBI: number of PEBs reserved for bad PEB handling: 9 UBI: max/mean erase counter: 11/7 UBI: image sequence number: 1006357712 UBI: background thread "ubi_bgt0d" started, PID 1456 UBI device number 0, total 972 LEBs (123420672 bytes, 117.7 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB) root@bosphorus-1:/#
To mount UBIFS,
root@bosphorus-1:/# mount -t ubifs ubi0:rootfs /mnt/point UBIFS: mounted UBI device 0, volume 0, name "rootfs" UBIFS: file system size: 120373248 bytes (117552 KiB, 114 MiB, 948 LEBs) UBIFS: journal size: 9023488 bytes (8812 KiB, 8 MiB, 72 LEBs) UBIFS: media format: w4/r0 (latest is w4/r0) UBIFS: default compressor: lzo UBIFS: reserved for root: 0 bytes (0 KiB)
U-Boot Bootargs Command for UBIFS
setenv bootargs console=ttyS2,115200 ubi.mtd=X,YYYY rootfstype=ubifs root=ubi0:rootfs rw
Where X is the MTD partition number being used for file system and YYYY is the NAND page size.Make sure that an UBI file system is flashed into this partition before passing it as a boot partition for Linux
Assuming mtd 5,
setenv bootargs console=ttyS2,115200 root=ubi0:rootfs ubi.mtd =5,2048 rw rootfstype=ubifs ip=dhcp saveenv
You can see how UBIFS is booting below.
UBIFS: mounted UBI device 0, volume 0, name "rootfs" UBIFS: file system size: 120373248 bytes (117552 KiB, 114 MiB, 948 LEBs) UBIFS: journal size: 9023488 bytes (8812 KiB, 8 MiB, 72 LEBs) UBIFS: media format: w4/r0 (latest is w4/r0) UBIFS: default compressor: lzo UBIFS: reserved for root: 0 bytes (0 KiB) VFS: Mounted root (ubifs filesystem) on device 0:13. Freeing init memory: 164K INIT: version 2.86 booting Please wait: booting... Starting udev udevd (626): /proc/626/oom_adj is deprecated, please use /proc/626/oom_score_adj instead. minix: disagrees about version of symbol module_layout modprobe: FATAL: Error inserting minix (/lib/modules/2.6.37/kernel/fs/minix/minix.ko): Invalid module format Root filesystem already rw, not remounting Caching udev devnodes Populating dev cachemv: cannot rename '/tmp/devices': No such file or directory logger: mount: mount point /proc/bus/usb does not exist ALSA: Restoring mixer settings... No state is present for card St Found hardware: "" "" "" "" "" Hardware is initialized using a generic method No state is present for card St Configuring e2fsprogs. update-alternatives: Error: cannot register alternative chattr to /usr/bin/chattr since it is already registered to /bin/chattr update-alternatives: Linking //sbin/uuidd to uuidd.util-linux-ng Configuring update-modules. ipv6: disagrees about version of symbol module_layout Configuring network interfaces... udhcpc (v1.13.2) started Sending discover... Sending select for 10.1.10.56... Lease of 10.1.10.56 obtained, lease time 172800 adding dns 10.1.2.88 adding dns 10.1.2.99 done. Setting up IP spoofing protection: rp_filter. INIT: Entering runlevel: 5 Starting telnet daemon. Starting syslogd/klogd: ipv6: disagrees about version of symbol module_layout modprobe: FATAL: Error inserting ipv6 (/lib/modules/2.6.37/kernel/net/ipv6/ipv6.ko): Invalid module format done Starting thttpdipv6: disagrees about version of symbol module_layout . ipv6: disagrees about version of symbol module_layout _____ _____ _ _ | _ |___ ___ ___ ___ | _ |___ ___ |_|___ ___| |_ | | _| .'| . | . | | __| _| . | | | -_| _| _| |__|__|_| |__,|_ |___| |__| |_| |___|_| |___|___|_| |___| |___| Arago Project http://arago-project.org bosphorus-1 ttyS2 Arago 2011.09 bosphorus-1 ttyS2 bosphorus-1 login: from:http://wiki.atlas-embedded.com/index.php?title=Creating_and_Flashing_UBIFS