Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have following problem - I damaged my system (Gentoo - by rebuilding using gcc 4.5) beyond repair. I unmounted /home, copied /etc + other important files and I've started reinstalling system.

However I forgot to copy init script. It is still present in kernel image that I have. How to extract it? Please note that initrd is not a separate file but is in the kernel image.

share|improve this question
I would be grateful for listing the contents as well. However I guess it'll be side effect of getting cpio archive. – Maciej Piechotka Apr 19 '10 at 14:20
I found… but I still fail to get the cpio from it. – Maciej Piechotka Apr 19 '10 at 15:45
up vote 0 down vote accepted

After unpacking by:

HDR=`binoffset bzImage 0x1f 0x8b 0x08 0x0`
dd if=bzImage bs=1 skip=$HDR | zcat - > kernel.unpack

(binoffset.c is in sources of Linux).

strings kernel.unpack | grep 070701

Gives the listing of archive. Just after the entry for /init in

strings kernel.unpack | less

Is the contents of script.

It is not perfect solution but at least it seems to work. Please answer if you know 'correct' way (for binaries) easy (not writing long program) - I'm not marking it as solution.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .