ubifs.txt 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. Introduction
  2. =============
  3. UBIFS file-system stands for UBI File System. UBI stands for "Unsorted
  4. Block Images". UBIFS is a flash file system, which means it is designed
  5. to work with flash devices. It is important to understand, that UBIFS
  6. is completely different to any traditional file-system in Linux, like
  7. Ext2, XFS, JFS, etc. UBIFS represents a separate class of file-systems
  8. which work with MTD devices, not block devices. The other Linux
  9. file-system of this class is JFFS2.
  10. To make it more clear, here is a small comparison of MTD devices and
  11. block devices.
  12. 1 MTD devices represent flash devices and they consist of eraseblocks of
  13. rather large size, typically about 128KiB. Block devices consist of
  14. small blocks, typically 512 bytes.
  15. 2 MTD devices support 3 main operations - read from some offset within an
  16. eraseblock, write to some offset within an eraseblock, and erase a whole
  17. eraseblock. Block devices support 2 main operations - read a whole
  18. block and write a whole block.
  19. 3 The whole eraseblock has to be erased before it becomes possible to
  20. re-write its contents. Blocks may be just re-written.
  21. 4 Eraseblocks become worn out after some number of erase cycles -
  22. typically 100K-1G for SLC NAND and NOR flashes, and 1K-10K for MLC
  23. NAND flashes. Blocks do not have the wear-out property.
  24. 5 Eraseblocks may become bad (only on NAND flashes) and software should
  25. deal with this. Blocks on hard drives typically do not become bad,
  26. because hardware has mechanisms to substitute bad blocks, at least in
  27. modern LBA disks.
  28. It should be quite obvious why UBIFS is very different to traditional
  29. file-systems.
  30. UBIFS works on top of UBI. UBI is a separate software layer which may be
  31. found in drivers/mtd/ubi. UBI is basically a volume management and
  32. wear-leveling layer. It provides so called UBI volumes which is a higher
  33. level abstraction than a MTD device. The programming model of UBI devices
  34. is very similar to MTD devices - they still consist of large eraseblocks,
  35. they have read/write/erase operations, but UBI devices are devoid of
  36. limitations like wear and bad blocks (items 4 and 5 in the above list).
  37. In a sense, UBIFS is a next generation of JFFS2 file-system, but it is
  38. very different and incompatible to JFFS2. The following are the main
  39. differences.
  40. * JFFS2 works on top of MTD devices, UBIFS depends on UBI and works on
  41. top of UBI volumes.
  42. * JFFS2 does not have on-media index and has to build it while mounting,
  43. which requires full media scan. UBIFS maintains the FS indexing
  44. information on the flash media and does not require full media scan,
  45. so it mounts many times faster than JFFS2.
  46. * JFFS2 is a write-through file-system, while UBIFS supports write-back,
  47. which makes UBIFS much faster on writes.
  48. Similarly to JFFS2, UBIFS supports on-the-flight compression which makes
  49. it possible to fit quite a lot of data to the flash.
  50. Similarly to JFFS2, UBIFS is tolerant of unclean reboots and power-cuts.
  51. It does not need stuff like fsck.ext2. UBIFS automatically replays its
  52. journal and recovers from crashes, ensuring that the on-flash data
  53. structures are consistent.
  54. UBIFS scales logarithmically (most of the data structures it uses are
  55. trees), so the mount time and memory consumption do not linearly depend
  56. on the flash size, like in case of JFFS2. This is because UBIFS
  57. maintains the FS index on the flash media. However, UBIFS depends on
  58. UBI, which scales linearly. So overall UBI/UBIFS stack scales linearly.
  59. Nevertheless, UBI/UBIFS scales considerably better than JFFS2.
  60. The authors of UBIFS believe, that it is possible to develop UBI2 which
  61. would scale logarithmically as well. UBI2 would support the same API as UBI,
  62. but it would be binary incompatible to UBI. So UBIFS would not need to be
  63. changed to use UBI2
  64. Mount options
  65. =============
  66. (*) == default.
  67. bulk_read read more in one go to take advantage of flash
  68. media that read faster sequentially
  69. no_bulk_read (*) do not bulk-read
  70. no_chk_data_crc (*) skip checking of CRCs on data nodes in order to
  71. improve read performance. Use this option only
  72. if the flash media is highly reliable. The effect
  73. of this option is that corruption of the contents
  74. of a file can go unnoticed.
  75. chk_data_crc do not skip checking CRCs on data nodes
  76. compr=none override default compressor and set it to "none"
  77. compr=lzo override default compressor and set it to "lzo"
  78. compr=zlib override default compressor and set it to "zlib"
  79. Quick usage instructions
  80. ========================
  81. The UBI volume to mount is specified using "ubiX_Y" or "ubiX:NAME" syntax,
  82. where "X" is UBI device number, "Y" is UBI volume number, and "NAME" is
  83. UBI volume name.
  84. Mount volume 0 on UBI device 0 to /mnt/ubifs:
  85. $ mount -t ubifs ubi0_0 /mnt/ubifs
  86. Mount "rootfs" volume of UBI device 0 to /mnt/ubifs ("rootfs" is volume
  87. name):
  88. $ mount -t ubifs ubi0:rootfs /mnt/ubifs
  89. The following is an example of the kernel boot arguments to attach mtd0
  90. to UBI and mount volume "rootfs":
  91. ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs
  92. References
  93. ==========
  94. UBIFS documentation and FAQ/HOWTO at the MTD web site:
  95. http://www.linux-mtd.infradead.org/doc/ubifs.html
  96. http://www.linux-mtd.infradead.org/faq/ubifs.html