# Managing the initial ramfs (initramfs) archive

The booting in Debian is a two-stage process, involving the initial RAM filesystem (initramfs for short, sometimes it is also referred to as initrd, which stands for initial RAM disk). First, the bootloader loads the kernel and initramfs into memory, and passes the execution control to the kernel. After basic initialization the kernel extracts the initramfs archive and mounts it as a temporary root filesystem. initramfs contains kernel modules and userspace programs required to initialize the physical or logical device(s) containing the real root filesystem. The `init` script on the initramfs loads modules and performs other necessary initialization steps. At the end of this stage `run-init` deletes the initramfs from memory, mounts the real root filesystem and passes control to the `/sbin/init` program on it.

Two major goals are achieved with such setup: the kernel size is kept under control by allowing most of the drivers to be compiled as modules (in a initramfs-less setup the drivers necessary for the boot-time initialization of the root device must be compiled into it) and allow the setups which require initialization which cannot be done in-kernel, but is performed by userspace utilities.

## Initramfs generation tools

Since initramfs usually needs to be customized for the particular hardware/device configuration and kernel version, they are not included as a part of any package, but are generated on the fly at kernel installation time. Currently there are two tools in Debian capable of generating an initramfs: `update-initramfs` provided by `initramfs-tools` (default) and `dracut-update-initramfs` provided by the `dracut` package (experimental).

## Regenerating the initramfs

If changes are desired after the corresponding `linux-image` has been installed, the initramfs needs to be regenerated. This is achieved by the command

    # dpkg-reconfigure linux-image-3.2.0-2-686-pae

where `linux-image-3.2.0-2-686-pae` is the name of the kernel package for which the initramfs regeneration is requested.

## Examining the initramfs contents

Occasionally it is useful to examine the contents of initramfs to diagnose a problem or for educational purposes. They are compressed `cpio` archives, which may be extracted using the command

    $ zcat /boot/initrd.img-3.2.0-2-686-pae | cpio -i

It will unpack the contents of the initramfs into the current directory.

It is also possible to list the contents of an initramfs using the `cpio` `-t` option or the command

    $ lsinitramfs /boot/initrd.img-3.2.0-2-686-pae