cramfs.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===========================================
  3. Cramfs - cram a filesystem onto a small ROM
  4. ===========================================
  5. cramfs is designed to be simple and small, and to compress things well.
  6. It uses the zlib routines to compress a file one page at a time, and
  7. allows random page access. The meta-data is not compressed, but is
  8. expressed in a very terse representation to make it use much less
  9. diskspace than traditional filesystems.
  10. You can't write to a cramfs filesystem (making it compressible and
  11. compact also makes it _very_ hard to update on-the-fly), so you have to
  12. create the disk image with the "mkcramfs" utility.
  13. Usage Notes
  14. -----------
  15. File sizes are limited to less than 16MB.
  16. Maximum filesystem size is a little over 256MB. (The last file on the
  17. filesystem is allowed to extend past 256MB.)
  18. Only the low 8 bits of gid are stored. The current version of
  19. mkcramfs simply truncates to 8 bits, which is a potential security
  20. issue.
  21. Hard links are supported, but hard linked files
  22. will still have a link count of 1 in the cramfs image.
  23. Cramfs directories have no ``.`` or ``..`` entries. Directories (like
  24. every other file on cramfs) always have a link count of 1. (There's
  25. no need to use -noleaf in ``find``, btw.)
  26. No timestamps are stored in a cramfs, so these default to the epoch
  27. (1970 GMT). Recently-accessed files may have updated timestamps, but
  28. the update lasts only as long as the inode is cached in memory, after
  29. which the timestamp reverts to 1970, i.e. moves backwards in time.
  30. Currently, cramfs must be written and read with architectures of the
  31. same endianness, and can be read only by kernels with PAGE_SIZE
  32. == 4096. At least the latter of these is a bug, but it hasn't been
  33. decided what the best fix is. For the moment if you have larger pages
  34. you can just change the #define in mkcramfs.c, so long as you don't
  35. mind the filesystem becoming unreadable to future kernels.
  36. Memory Mapped cramfs image
  37. --------------------------
  38. The CRAMFS_MTD Kconfig option adds support for loading data directly from
  39. a physical linear memory range (usually non volatile memory like Flash)
  40. instead of going through the block device layer. This saves some memory
  41. since no intermediate buffering is necessary to hold the data before
  42. decompressing.
  43. And when data blocks are kept uncompressed and properly aligned, they will
  44. automatically be mapped directly into user space whenever possible providing
  45. eXecute-In-Place (XIP) from ROM of read-only segments. Data segments mapped
  46. read-write (hence they have to be copied to RAM) may still be compressed in
  47. the cramfs image in the same file along with non compressed read-only
  48. segments. Both MMU and no-MMU systems are supported. This is particularly
  49. handy for tiny embedded systems with very tight memory constraints.
  50. The location of the cramfs image in memory is system dependent. You must
  51. know the proper physical address where the cramfs image is located and
  52. configure an MTD device for it. Also, that MTD device must be supported
  53. by a map driver that implements the "point" method. Examples of such
  54. MTD drivers are cfi_cmdset_0001 (Intel/Sharp CFI flash) or physmap
  55. (Flash device in physical memory map). MTD partitions based on such devices
  56. are fine too. Then that device should be specified with the "mtd:" prefix
  57. as the mount device argument. For example, to mount the MTD device named
  58. "fs_partition" on the /mnt directory::
  59. $ mount -t cramfs mtd:fs_partition /mnt
  60. To boot a kernel with this as root filesystem, suffice to specify
  61. something like "root=mtd:fs_partition" on the kernel command line.
  62. Tools
  63. -----
  64. A version of mkcramfs that can take advantage of the latest capabilities
  65. described above can be found here:
  66. https://github.com/npitre/cramfs-tools
  67. For /usr/share/magic
  68. --------------------
  69. ===== ======================= =======================
  70. 0 ulelong 0x28cd3d45 Linux cramfs offset 0
  71. >4 ulelong x size %d
  72. >8 ulelong x flags 0x%x
  73. >12 ulelong x future 0x%x
  74. >16 string >\0 signature "%.16s"
  75. >32 ulelong x fsid.crc 0x%x
  76. >36 ulelong x fsid.edition %d
  77. >40 ulelong x fsid.blocks %d
  78. >44 ulelong x fsid.files %d
  79. >48 string >\0 name "%.16s"
  80. 512 ulelong 0x28cd3d45 Linux cramfs offset 512
  81. >516 ulelong x size %d
  82. >520 ulelong x flags 0x%x
  83. >524 ulelong x future 0x%x
  84. >528 string >\0 signature "%.16s"
  85. >544 ulelong x fsid.crc 0x%x
  86. >548 ulelong x fsid.edition %d
  87. >552 ulelong x fsid.blocks %d
  88. >556 ulelong x fsid.files %d
  89. >560 string >\0 name "%.16s"
  90. ===== ======================= =======================
  91. Hacker Notes
  92. ------------
  93. See fs/cramfs/README for filesystem layout and implementation notes.