Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Create a CRAMFS Target Image

From Texas Instruments Wiki
Jump to: navigation, search


The compressed ROM file system (cramfs) is a read-only Linux file system designed to have a small footprint. The main difference between cramfs and a compressed image of a traditional file system is that the cramfs file system can be used without the need to decompress it first. This is accomplished by compressing the file system one page at a time, which allows for random read access. However, this also prevents writing to the file system.

Benefits of CRAMFS

  1. CRAMFS file systems have a small footprint.
  2. CRAMFS file systems can be read without needed to decompress the entire file system first.

Limitations of CRAMFS

  1. CRAMFS file systems are read-only.
  2. CRAMFS file systems have a max size per file of 16MB.
  3. CRAMFS file systems have a max file system size of a little over 256MB. This is because the last file on the file system must begin before the 256MB mark but may extend past the 256MB mark.


  • CRAMFS utilities for creating the CRAMFS file system image.
    • For more information on obtaining and installing the CRAMFS utilities please see the CRAMFS Utilities page.
  • A target (ARM) root file system which you want to create a CRAMFS image of (e.g. the content of a ramdisk or NFS share).

Creating a CRAMFS Target Image

The following section will walk you through how to create a CRAMFS target image that can be placed in Flash on the DVEVM. To save time, a RAM disk is provided with the DVSDK ARM Linux software. This RAM disk can be used as a base for our cramfs file system image. For newer versions of the DVSDK (DVSDK 1.30 and greater) the sample ramdisk file system can be found at <DVSDK install dri>/<PSP directory>/bin. In older versions of the DVSDK (DVSDK 1.20 and earlier) the sample ramdisk file system can be found in the MontaVista installation directory at <MV install dir>/montavista/pro/devkit/arm/v5t_le/images.

the RAM disk file is called ramdisk.gz (about 2.1 MB gunzipped). In run time, it occupies about 6.3 MB in DDR. This file system contains some unnecessary utilities for this project, but is appropriate for a typical embedded system. We are going to use this file system to generate a cramfs file system. The following steps will demonstrate how to create a cramfs file system image.

  • Copy the example initial RAM disk to a temporary location
   host $ mkdir –p /mnt/def_cd
   host $ cp <path to ramdisk>/ramdisk.gz /mnt/def_cd
   host $ cd /mnt/def_cd
  • Mount the example initial RAM disk image
   host $ gunzip ramdisk.gz
   host $ mkdir ram0
   host $ mount ramdisk ram0 –o loop
  • Modify the example initial RAM disk. You can add new applications or files at this point. For a more detailed example of adding a new application see the [SPRAAH2] document. For this example we will add a simple shell script to print “Hello World!!!” on start-up.
   host $ vi ram0/etc/init.d/
   Add the following 2 lines into the file:
   echo “Hello World!!!”
   host $ chmod +x ram0/etc/init.d/
   host $ cd ram0/etc/rc.d/rcS.d
   host $ ln –s ../init.d/ S50hello
   host $ cd /mnt/def_cd
  • Create a cramfs image of the file system
   host $ mkcramfs ram0 cramfs.image
  • Un-mount the example initial RAM disk
   host $ umount ram0


You should now have a file /mnt/def_cd/cramfs.image which is a CRAMFS image to the sample ramdisk file system with a script to print "Hello World!!!" on start-up. This image can now be placed in Flash for use as a root file system for the Linux kernel. For information on how to use this image please see the Put CRAMFS Image to Flash page.