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.

link|improve this question

80% accept rate
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 cs.caltech.edu/~weixl/research/fast-mon/scripts/… but I still fail to get the cpio from it. – Maciej Piechotka Apr 19 '10 at 15:45
feedback

1 Answer

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.