Viewing the contents of an initrd image


I was doing some research tonight, and needed to look inside my initrd image to see if a couple of device drivers were present. Initrd images are stored as compressed cpio archives, which allows a pipeline like the following to be used to extract the contents of an image:

$ gunzip < initrd-2.6.29.4-167.fc11.x86_64.img | cpio -i --make-directories 14050 blocks

Once extracted, you can use cd and cat to view the files and directories that are part of the image:

$ ls -l

drwxrwxrwt. 11 root root 4096 2009-07-14 23:30 .
drwxr-xr-x. 23 root root 4096 2009-07-07 14:55 ..
drwx------ 2 root root 4096 2009-07-14 23:30 bin
drwx------ 3 root root 4096 2009-07-14 23:30 dev
drwx------ 4 root root 4096 2009-07-14 23:30 etc
-rwx------ 1 root root 1938 2009-07-14 23:30 init
-rw------- 1 root root 3428816 2009-07-14 23:29 initrd-2.6.29.4-167.fc11.x86_64.img
drwx------ 6 root root 4096 2009-07-14 23:30 lib
drwx------ 2 root root 4096 2009-07-14 23:30 lib64
drwx------ 2 root root 4096 2009-07-14 23:30 proc
lrwxrwxrwx 1 root root 3 2009-07-14 23:30 sbin -> bin
drwx------ 2 root root 4096 2009-07-14 23:30 sys
drwx------ 2 root root 4096 2009-07-14 23:30 sysroot
drwx------ 4 root root 4096 2009-07-14 23:30 usr

$ ls -l etc

total 20
-rw-r--r-- 1 root root 29 2009-07-14 23:30 fedora-release
-rw-r--r-- 1 root root 1976 2009-07-14 23:30 ld.so.cache
-rw-r--r-- 1 root root 28 2009-07-14 23:30 ld.so.conf
drwx------ 2 root root 4096 2009-07-14 23:30 ld.so.conf.d
drwx------ 2 root root 4096 2009-07-14 23:30 sysconfig
lrwxrwxrwx 1 root root 14 2009-07-14 23:30 system-release -> fedora-release
This article was posted by Matty on 2009-07-14 23:32:00 -0400 EDT