Search This Blog

Monday, September 09, 2013

View the Content of initrd image in Linux

The initial RAM disk is an initial root file system that is mounted prior to when the real root file system is available.

How can the content of initrd can be viewed?

Go to the /boot directory of linux and copy the initrd file to another location.

1. Create a folder

[ajasoman@oc1120611582 ~]$ mkdir initrd

2. Change to that directory and copy the initrd file to there..

[ajasoman@oc1120611582 ~]$ cd initrd

[ajasoman@oc1120611582 initrd]$ cp /boot/initramfs-2.6.32-358.11.1.el6.x86_64.img /home/ajasoman/initrd

[ajasoman@oc1120611582 initrd]$ ls initramfs-2.6.32-358.11.1.el6.x86_64.img

3. Rename the file to .gz

mv initramfs-2.6.32-358.11.1.el6.x86_64.img initramfs-2.6.32-358.11.1.el6.x86_64.gz

4. Use gunzip command to un-compress the file

gunzip initramfs-2.6.32-358.11.1.el6.x86_64.gz

5. Use cpio command to convert

[ajasoman@oc1120611582 initrd]$ cpio -ivd < initramfs-2.6.32-358.11.1.el6.x86_64
.
initqueue-finished
proc
pre-udev
pre-udev/30block-genrules.sh
pre-udev/30dmsquash-liveiso-genrules.sh
pre-udev/30dm-pre-udev.sh
pre-udev/30resume-genrules.sh
pre-udev/30mdmon-pre-udev.sh
dracut-004-303.el6
lib64
lib64/li
6. See the o/p using ls 

[ajasoman@oc1120611582 initrd]$ ls -l
total 50300
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 bin
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 cmdline
drwxr-xr-x 3 ajasoman ajasoman     4096 Sep  9 23:40 dev
-rw-r--r-- 1 ajasoman ajasoman       19 Sep  9 23:40 dracut-004-303.el6
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 emergency
drwxr-xr-x 7 ajasoman ajasoman     4096 Sep  9 23:40 etc
-rwxr-xr-x 1 ajasoman ajasoman     8879 Sep  9 23:40 init
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 initqueue
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 initqueue-finished
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 initqueue-settled
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 initqueue-timeout
-rw-r--r-- 1 ajasoman ajasoman 51398656 Sep  9 23:11 initramfs-2.6.32-358.11.1.el6.x86_64
drwxr-xr-x 7 ajasoman ajasoman     4096 Sep  9 23:40 lib
drwxr-xr-x 4 ajasoman ajasoman     4096 Sep  9 23:40 lib64
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 mount
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 pre-pivot
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 pre-trigger
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 pre-udev
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 proc
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 sbin
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 sys
drwxr-xr-x 2 ajasoman ajasoman     4096 Sep  9 23:40 sysroot
drwxrwxrwt 2 ajasoman ajasoman     4096 Sep  9 23:40 tmp
drwxr-xr-x 7 ajasoman ajasoman     4096 Sep  9 23:40 usr
drwxr-xr-x 4 ajasoman ajasoman     4096 Sep  9 23:40 var
[ajasoman@oc1120611582 initrd]$


No comments: