LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to unpack an Ubuntu or Fedora initrd file (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-unpack-an-ubuntu-or-fedora-initrd-file-819173/)

dar_beh_dar 07-11-2010 01:13 AM

How to unpack an Ubuntu or Fedora initrd file
 
Hi everyone,

I have read the Landley articles on the web as well as the relevant files under 'Documentation' in the kernel source.

I have come to understand ( correct/incorrect ? ) that the 'image' file that is extracted into the 'rootfs' ( which itself is a fixed 'ramfs' filesystem available at boot-time ) by the kernel is a 'cpio' archive containing modules and the 'init' executable to facilitate the kernel's transition into userpace.

That all sounds fine and reasonable. But can anyone tell me >how< to actually extract the contents of such a file that comes with one's distro?

Assuming an X-ubuntu distro, how does one extract the contents of
'initrd.img-2.6.28-11-generic' for example, to examine what's in it?


I have tried various forms of the 'cpio' command

i) cpio -t < initrd.img-2.6.28-11-generic

ii) cpio -idv < initrd.img-2.6.28-11-generic

or even

iii) cpio -i -d -H newc -F initrd.img-2.6.28-11-generic --no-absolute-filenames

None of the above seem to work.

I get:
.................
cpio: Malformed number
cpio: Malformed number
cpio: Malformed number
cpio: warning: skipped 14766 bytes of junk
cpio: warning: archive header has reverse byte-order
.................

as in the case of ii) or:

cpio: premature end of file

as under iii).

a) What am I doing wrong?
b) What is wrong in my understanding?
c) Can you give me one example of how to correctly unpack and view the
contents of one of these files?


Regards

Reza Mostafid

raskin 07-12-2010 01:41 AM

Well, actually initrd is compressed and cpio can't handle it.

Try using "file" utility to find out its format and reverse the operations step-by-step.

Actually, you need to run gunzip on initrd first.

bsat 07-12-2010 02:54 AM

yes as raskin said initrd is a gunzip archive try the following

mv initrd-2.6.15-generic initrd-2.6.15-generic.gz
gzip -d initrd-2.6.15-generic.gz
cpio -i < initrd-2.6.15-generic

dar_beh_dar 07-14-2010 06:11 AM

Hi bsat,
Hi raskin,

I tried your suggestions and it worked...great many thanks to you for helping me out with this...I had always been curious to look at on eof these things...it's like you helped me scratch an itch.

Regards

Reza


All times are GMT -5. The time now is 06:07 AM.