Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 07-11-2010, 01:13 AM   #1
LQ Newbie
Registered: Aug 2006
Distribution: Fedora
Posts: 21

Rep: Reputation: 1
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?


Reza Mostafid
Old 07-12-2010, 01:41 AM   #2
Senior Member
Registered: Sep 2005
Location: Russia
Distribution: NixOS (
Posts: 1,899

Rep: Reputation: 68
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.
1 members found this post helpful.
Old 07-12-2010, 02:54 AM   #3
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
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
1 members found this post helpful.
Old 07-14-2010, 06:11 AM   #4
LQ Newbie
Registered: Aug 2006
Distribution: Fedora
Posts: 21

Original Poster
Rep: Reputation: 1
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's like you helped me scratch an itch.




Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I unpack a .gzip file? abefroman Linux - Server 4 11-09-2009 01:21 PM
How to create new initrd.gz (or initrd.img) file? kkpal Programming 2 12-10-2007 08:38 AM
how to unpack a file? kuertensun Linux - Newbie 11 06-22-2005 01:32 PM
How to unpack an ISO file Scrag Linux - Software 6 02-06-2005 04:31 AM
How to unpack a bz2 file? threepennybit Linux - Software 5 12-12-2004 04:05 AM

All times are GMT -5. The time now is 10:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration