In this tutorial i will guide you how to modify an existing initramfs with your own changes – and inject it back into the zImage file, ready to be distributed and flashed.
I assume the followings:
(a) You are familiar with Linux CLI.
(b) Your zImage file is extracted and in your current directory.
WARNING: USE THIS ON YOUR OWN RISK.
1. Use the following script to extract initramfs.img from zImage
2. As noted in the previous link, to extract your newly created initramfs.img, use:
cpio -i --no-absolute-filenames < initramfs.img
3. Make whatever changes you like – copy su/busybox/etc, patch startup script, etc.
4. Delete initramfs.img (so it won’t be included when generating a new initramfs.img from the current directory)
5. To create a new initramfs.img use:
find . | cpio -H newc -o > ../initramfs.img
This will create initramfs.img in the directory above your current one.
6. Use the following script to replace your newly created initramfs.img with the original one.
A new file named new_zImage will be created – thats your new kernel+initramfs.img. rename it to zImage.
7. Use either method to flash your new zImage:
(a) Create update.zip to flash your kernel
(b) tar the zImage and flash using Odin on Windows.