linux poison RSS
linux poison Email

How to view the contents of an initrd image

Linux uses the initrd or initial ram-disk during the boot process. Linux kernel is very modular as you know. While the kernel main file contains only the most needed stuff, rest of the kernel, drivers included, reside in separate files – the kernel modules.

It would be impossible to create a single kernel binary image that would suit all the hardware configurations out there. Instead, kernel supports the initrd. initrd is a virtual file-system that contains drivers (kernel modules) needed to boot the system. For instance, very often a SCSI controllers drivers reside inside of the initrd. Kernel needs a SCSI controller driver to boot the operating system, but it does not include it, nor it can read it from hard-disk (you’d need a driver for the hard-disk, right?). And this is when the initrd becomes very handy.

To extract the content of initrd file, use the following command:

gunzip < initrd-2.6.31.5-0.1-desktop | cpio -i --make-directories



2 comments:

ben said...

well, to view --list seems sufficient , according to :
from : http://www.gnu.org/software/cpio/manual/cpio.html

scary :

--make-directories
Create leading directories where needed.

"initrd is a virtual file-system that contains drivers (kernel modules) needed to boot the system" which means it does contains "/" so you would overwrite the filesystem on which you run it , then run for your last backup tape from hopefully not from 1928 :(

i prefer :

--no-absolute-filenames
Create all files relative to the current directory in copy-in mode, even if they have an absolute file name in the archive.

then the nirvana opens up to you ;)

unless your cpio has some other safer options enabled by default .

Anonymous said...

View modules
gunzip < initrd-2.6.18-308.el5.img | cpio -t | grep "ko" | less

Post a Comment

Related Posts with Thumbnails