How to extract and see what is inside an initrd or initramfs

How can I list the content of an initrd or initramfs file without extracting it?

zcat initramfs_xxx.img | cpio -it  
zcat initramfs_xxx.img | cpio -it | grep something

How do I extract the content of the file?

mkdir /tmp/stuff
cp /boot/initramfs-xxxx.img  /tmp/stuff/
cd /tmp/stuff/
zcat initramfs-xxx.img  | cpio  -id

What format is the initrd or initramfs file? Why do we need a combination of zcat and cpio to extract it?

It is a gzip compressed cpio archive file. Hence we need zcat and cpio to tear it apart.

mkdir /tmp/stuff
cp /boot/initramfs-xxxx.img  /tmp/stuff/
cd /tmp/stuff/

Find out what type of file it is.

file initramfs-xxxx.img
initramfs-xxxx.img: gzip compressed data, from Unix, last modified: Tue Nov  1 15:02:43 2016, max compression

Rename it to .gz so we can uncompress it using gunzip.

mv initramfs-xxxx.img initramfs-xxxx.img.gz
gunzip  initramfs-xxxx.img.gz

Find out the type of the uncompressed file.

file initramfs-xxxx.img
initramfs-xxxx.img: ASCII cpio archive (SVR4 with no CRC) 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s