From LQWiki
Jump to: navigation, search

An initrd (Initial RamDisk) is essentially a filesystem in-a-can. It is a (typically gzip) compressed file which contains a functional filesystem containing various files depending on its intended function. One popular use of an Initrd is for a framebuffer image to display during bootup, using programs such as bootsplash. It has many more functional uses however, such as being a place where modules can be placed that will automatically get loaded on boot up, which is handy for many reasons. Most off the shelf distros like using an initrd file on a standard installation, but they are not strictly required normally.

initrd files can be created using the mkinitrd command.

Examining an initrd

Supposing you have an initrd file you wish to examine, named initrd-file. First find out what file type it is:

file initrd-file

It can be a

  • pure ramdisk
  • cpio archive
  • gzipped cpio archive
in this case you would see something like this:
# file initrd-file
initrd-file: gzip compressed data, was "build.initramfs", from Unix
  • cramfs image
in this case you can see something like this:
file initrd-file
Linux Compressed ROM File System data

pure ramdisk

The following commands should show you what's inside:

mkdir idir
losetup /dev/loop/0 initrd-file
mount /dev/loop/0 idir
ls idir


umount idir
losetup -d /dev/loop/0


  • The device may need to be /dev/loop0 (depending on your kernel version) or even a different number, if loop 0 is in use.


mount -t cramfs /dev/loop/0 idir


As discussed, the initrd may be a cpio packed file. To unpack this, you will have to use the command

cpio -id <../initrd.img

To pack it again (if you changed the content), you will have to use

find . | cpio --create --format='newc' > ../newinitrd

See also