LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 07-11-2010, 01:13 AM   #1
dar_beh_dar
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?


Regards

Reza Mostafid
 
Old 07-12-2010, 01:41 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
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
bsat
Member
 
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
dar_beh_dar
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 things...it's like you helped me scratch an itch.

Regards

Reza
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

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

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