View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Initrd

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.

See also:

Examining an initrd

Supposing you have an initrd file you wish to examine, named initrd-file. The following commands should show you what's inside:

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

Later:

  umount idir
  losetup -d /dev/loop/0

Variations:

  • The device may need to be /dev/loop0 (depending on your kernel version) or even a different number, if loop 0 is in use.
  • The kernel may insist that you specify the filesystem type to mount. Type file initrd-file to figure out what it is. If it says Linux Compressed ROM File System data, it's cramfs:
  mount -t cramfs /dev/loop/0 idir
  • file initrd-file might point you to the fact that the initrd is a cpio archive. 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

Personal tools