Sunday, June 20, 2010

UBIFS how to ^_^

UBIFS howto:


STEP 1:Install UBIFS tools with the follow packages. If you have the mkfs.ubifs then go to

Step 2 Use UBI
1. config kernel option and compile UBI / UBIFS /ext2 into the kernel
(1) Enable UBI and Emulate MTD devices
Path:
"Device Drivers"
-> "Memory Technology Device (MTD) support"
-> "UBI - Unsorted block images",

(2) Enable UBIFS
Path:
"File systems"
-> "Miscellaneous filesystems"
-> "UBIFS file system support"
(2) Enable Ext2
Path:
"File systems"
-> " Second extended fs support "

2. make image
(1)create UBIFS rootfs image
mkfs.ubifs -r filesys/ -m 4096 -e 516096 -c 2047 -o ubifs.img
ubinize -o ubi.img -m 4096 -p 512KiB ubinize.cfg

where ubinize.cfg contains:
[ubifs]
mode=ubi
image=ubifs.img --rootfs image name
vol_id=0
vol_size=128MiB --volume size
vol_type=dynamic
vol_name=ubifs ---UBI volume name
vol_flags=autoresize


3. mount rootfs
(1) mount ubifs root file system on redboot
fis load kernel
exec -c "noinitrd console=ttymxc0,115200 ubi.mtd=2 root=ubi0:ubifs rootfstype=ubifs rw"

(*assume the kernel had 5 partitions. But the UBI will create new partition when attach the UBI ,so root=/dev/mtdblock6)

4 mount a partition via UBI
(1) ubifs
ubiformat /dev/mtdXX
ubiattach /dev/ubi_ctrl -m XX
ubimkvol /dev/ubi0 -N ubi_name -s 512MiB
mount -t ubifs ubi0:ubi_name /mnt/ubifs
ubiupdatevol /dev/ubi0_0 –t - wipe out an existing UBI volume


Note:
About -o sync option in mount, this will make UBIFS to run in synchronous mode, which will disable write-back cache and small write buffers.
If -o sync is not used in mount, then we should run “sync” (symbolic link to BusyBox), to sync write-back cache and small write buffers to NAND, before we reset Dickens.
Above being said, as we don’t have a mechanism to power down gracefully, UBIFS synchronous mode (-o sync) is recommended at this moment.

No comments: