Creating an Initial RAM Disk

An initial RAM disk (either an initrd or a initramfs) is a filesystem image that is generally compressed and bundled with a kernel. It provides a filesystem from which the kernel can execute programs and load kernel modules as part of the boot process, enabling you to perform administrative tasks before using or mounting any devices, and minimizing the number of device drivers that you must build into your kernel.

In embedded systems, the kernel often mounts the filesystem stored in the initrd as the primary RFS. This eliminates the need to mount a filesystem over a network (described in Using a Remotely-Mounted Filesystem), or to manage disk partitions on an embedded development board.

Using an initial RAM disk has two potential problems. First, embedded systems with extremely limited amounts of RAM may not have enough additional space to hold the filesystem image. Second, an initial RAM disk provides no long-term storage – each time that you boot your embedded Linux system, the initial RAM disk is reloaded from the compressed image, which cannot be updated without recompilation. For these reasons, embedded systems with local storage typically install a root filesystem there. This takes full advantage of your available hardware and, in the case of writable storage media such as flash, compact flash, Disk-on-Chip, or devices such as hard drives, provides a location where your system can maintain state and log information across reboots.

Linux distributions that can use an initial RAM disk can either access an initial RAM disk image that is embedded in the kernel image, or can use a separately loaded initial RAM disk. On Linux systems that use the GRUB (Grand Unified Boot Loader) boot loader, the system’s initial RAM disk is typically located in the /boot directory and is identified in the GRUB configuration file (/etc/grub.conf). On most embedded systems, the initial RAM disk is created as a file external to the kernel, but is bundled with the kernel as a final step in the kernel build process.

Although initrds are usually bundled with a kernel, they are not necessarily compiled into the kernel image a board boots. The x86 architecture, for example, and some XScale targets, do not support initrds that are part of the kernel image. Rather, the initrd is a separate file downloaded after the kernel starts and then mounted and used (often using the pivot_root utility).

Creating and using an initrd image can be separated into three steps:

  1. Creating a small root filesystem

    If you are using a pre-existing initial RAM disk image, or are going to create an initrd from the command line, you need to configure the kernel to access the image, and then uncompress and mount the image. For more information, refer to:

  2. Packaging the initrd image
  3. Copying the initrd image to the target

TimeStorm Target Configurator can be helpful in all of these areas.


Also see:

Using the Initial RAM Disk (initrd)
Target Configurator Documentation