How to unpack/repack initramfs in zImage
Here we go.
I'm saying that I'm not a very good developer so this information could be messy, contain unnecessary works or a bit wrong.
And also I'm not sure if this method will work with every zImage from every device.
I've tested with
I9000-JM2/JM7 : ECLAIR
JPC : FROYO
and they work like a charm.
OK, now we start.
Download this file
It has cross-compiler in it so that it's slightly big.
This is basically for devs so I won't tell you specifically. (or I can't...maybe)
1. Extract cpio'ed initramfs file from zImage.
: In order to extract initramfs.cpio, go through from step4 to step11.
A file which starts with "30 37 30" means that this is a cpio'ed file.
So, trim the Image-Orig file from the beginning to the point just before "30" then, you've got a cpio compressed file.
You can now simply decompress it.
cat initramfs.cpio | cpio -i --no-absolute-filenames
2. Decompress and edit these files. Make sure you shouldn't go over the original size. (simply, I removed redbend_ua in /sbin forder)
3. Recompress to cpio. ( I've used scripts/gen_initramfs_list.sh which is in the kernel source for a safe bet)
: What I've done is here. chdir to "zImage_repack/2.6.29" forder then
/bin/bash scripts/gen_initramfs_list.sh -o usr/initramfs_data.cpio -u 0 -g 0 /home/zero/Desktop/JPC/initramfs/i9000_initramfs_list
4. open the zImage with a hexeditor.
5. find "1f 8b 08".
6. cut off from the beginning to the point just before the "1f" so that this file begins with "1f 8b 08".
7. save as anyname.gz
8. in terminal >>>> gunzip anyname.gz
Now, you've got an Image file. I'll call this as an Image-Orig.
9. open the Image-Orig file with a hexeditor.
10. remember the entire size of this file. One of mine was "0xb9a5df".
11. find "30 37 30" hexademical code and "TRAILER!!!" text.
12. cut off from the first "30" to the last "!".
an example is here
13. open the cpio file you had recompressed with the hexeditor.
14. paste this codes to the exactly same place where the former initramfs was, in Image-Origin file. (Up to now, I feel like English is more difficult than this trick...sigh, sorry for my bad english!)
15. Almost done. We're gonna make the modified Image file's size identically to the Image-Orig. It's simple. just fill the hole with a bunch of NULLs. put your finger on "0" button and have a little sleep.
I think I need a visual assistant.
Save it as "Image".
At this point, you should have an Image file which size is the same as Image-Orig.
Now open the file you've downloaded at the first.
there is a forder called place_Image_here
yeah, place the Image there and execute the "Repack_kernel.sh" file.
In several seconds, you'll have a zImage file.
I'm so tired and I can't last this writing so, if you have any question, I'll give you a reply.
: I've attached the modified JPC kernel which supports /system/etc/init.d/userscripts.sh
It's named JPC_modified_kernel.tar.zip and you should take the ".zip" off in order to use with Odin.
: I've compiled gnu_parted! also attached. good luck, RyanZA!
-info : GNU parted v2.2 (original version, didn't apply bug fixes.)
disabled device-mapper and read-line while compiling, does this matter?