ubifs in Astfin 2.1

ubifs support was added in Astfin 2.1
20 September 2009

Let me put a short introduction about the different flash based file systems.
This will explain why we have decided to migrate Astfin 2.1 to ubifs

Few years ago there was two popular flash based file systems, jffs2 and yaffs2.
jffs2 (Journalling Flash File System) is actually the dinosaurs of the flash based file systems with lot of nice features like, compression support, power-down resistant, wear-leveling. It was designed however some time in the past and it is intended mostly for small partitions (<10MiB). As a result for bigger flash memories it takes very long time to mount the partition and it uses lot of RAM.

The alternative was yaffs2 (Yet Another Flash File System). yaffs2 supports everything what jffs2 supports except the compression. In addition yaffs2 is smarter, developed for bigger flashes in mind. It mounts the partitions much quicker than jffs2, and it has better read/write speed. In addition it takes less RAM. Taking those features in mind it is clear why few years ago people started to migrate from jffs2 to yaffs2, especially for the situations when compression is not needed like storage of already compressed data (zip, tgz, mp3 etc)

However nothing is ever perfect. yaffs is not perfect as well. The main problem except the lack of compression is something experts call partition scalability.
With other words, what happens with the speed, RAM consumption, CPU usage of the file system when the size of the partition increases. Both jffs2 and yaffs2 scale linear versus size of the partition which makes them not very good for partitions above 100MiB. So it didn’t take long time and we saw new players. Most popular are LogFS and ubifs.


LogFS
working directly on top of MTD devices and is meant to replace jffs2 as it is well scalable for big partitions. It adds some nice features to the file system portfolio (like snapshots for example) but it seems still work in progress.

The new generation flash file system, containing all of the features mentioned above including compression is ubifs
ubifs
is scalable in terms of partition size. It has neat journal and fast garbage collector.
In addition ubifs can postpone writing to the flash chip (write-back caching) which can speed up file system operations dramatically in some cases. ubifs is not working directly on top of the MTD devices. It needs an extra UBI (Unsorted Block Images) layer which in its core does a mapping between the logical blocks (which are used by ubifs) and the physical erase block on the flash chip.
Splitting the file system in two layers helps the developers to divide the complex task in to simpler subtasks
ubifs is already in the Linux mainstream which makes it very easy for adoption

In order to use ubifs first we need ubi device. Fortunately there is an users space tool for it.
To create ubi0 device on top of mtd3 flash you can do
ubiattach /dev/ubi_ctrl –mtdn=3 –devn=0
You need ubi_ctrl node on your devfs with major 10 and minor 63.

First time you use ubi0 you need to make a volume on top of it. To create 900MiB volume with name test you can do
ubimkvol /dev/ubi0 -s 900MiB -N test
You need an ubi0 node with major 253 and minor 0 to perform this step.

Finally you can mount directory /ubifs_test using ubifs like this
mount -t ubifs ubi0 /ubifs_test

Have fun :-)
Dimitar Penev

This entry was posted in Hardware. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

You must be logged in to post a comment.