4

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.

quack quixote
  • 43,504

1 Answers1

1

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.