Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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