# [HOW TO] Create an AnyKernal Flashable Zip from a boot.img



## wraithdu

First off, I know this is possible with the Android Kitchen, but I think there's an easier way to do it on your phone. You can to do it through an ADB terminal with a computer, or from a terminal emulator. Your choice of method will influence how you transfer files to and from your phone however.

Stuff you'll need:

1) The AnyKernel package from Ziggy. Sorry, you'll need to register to download the file. You can read a bit about it in the post.

*AnyKernel for Thunderbolt from PPCGeeks*

2) The boot.img and bundled modules from a kernel you want to use.

Here we go:

*1) Prepare the files*
- Extract the boot.img from the kernel package you want to prepare.
- Extract 'unpackbootimg' from the 'kernel' directory of the AnyKernel package.
- On your phone, make a directory /data/anykernel
- Copy the boot.img and 'unpackbootimg' to the new directory. You can 'adb push' these files or mount your sdcard to copy them there, then use a file manager.
- Set permissions on 'unpackbootimg' to make it executable. You can do this with a file manager like RootExplorer, an adb shell, or from a terminal emulator. Make sure you are in a root terminal (type 'su' if needed).


Code:


chmod 755 /data/anykernel/unpackbootimg

*2) Extract the kernel zImage*
- This is the easy part. From a terminal run these commands. Note that the . (period) and / (slash) are required.


Code:


cd /data/anykernel<br />
./unpackbootimg boot.img

- There will now be several new files in your anykernel directory. Copy the 'boot.img-zImage' file back to your computer (the method is at your discretion).
- You can now remove the whole /data/anykernel directory. Or you can remove the boot.img files and keep the directory and unpackbootimg around for future use, up to you.

*3) Package the new AnyKernel flashable zip*
- Rename your new 'boot.img-zImage' file to 'zImage', no extension.
- Make a copy of the AnyKernel.zip package and rename it to something relevant to the kernel you are packaging.
- Add the new 'zImage' to the 'kernel' directory in the zip file.
- Extract everything from the /system/lib/modules directory of the ORIGINAL KERNEL package, and add them to the /system/lib/modules directory of the new AnyKernel package.

That's it. You can now copy the new AnyKernel package to your sdcard and flash it over any compatible ROM. If you are comfortable with this process, it's trivial to write a shell script to take care of most of it, but that is beyond the scope of this quick tutorial.

*UPDATE: Quick Shell Script*
Here's a quick shell script to automate most of this. To use it, copy the 'boot.img' and 'unpackbootimg' to a directory on your sdcard, ie '/sdcard/anykernel'. Create a new script in the same directory, for example 'makezimage.sh', and copy the below code into it. To run it, open a root terminal either in an emulator or adb and issue the following commands:


Code:


cd /sdcard/anykernel<br />
sh makezimage.sh

The unpacked zImage will be left in the same directory.

*makezimage.sh*


Code:


#!/system/bin/sh<br />
<br />
DEST="/data/local/anykernel"<br />
<br />
rm -f -r $DEST<br />
mkdir $DEST<br />
cp boot.img $DEST/<br />
cp unpackbootimg $DEST/<br />
chown 0:0 $DEST/unpackbootimg<br />
chmod 755 $DEST/unpackbootimg<br />
$DEST/unpackbootimg $DEST/boot.img $DEST/<br />
rm -f /sdcard/anykernel/zImage<br />
cp $DEST/boot.img-zImage /sdcard/anykernel/zImage<br />
rm -f -r $DEST

DISCLAIMER: I take no resposibility for you flashing an incompatible kernel or your sister's 3rd grade english paper and bricking your phone.


----------



## 00negative

Uh sorry, ihtfp69 link for his anykernel has been removed, use Ziggy's from post above.


----------



## jdkoreclipse

Not to try to derail the thread any longer, but I too have a version of anykernel on my github.....http://github.com/jdkoreclipse/AnyKernel


----------



## wraithdu

I don't think the source of the binaries is really in question here, so much as what to do with them.

BTW, ihtfp69 pulled his link, which just goes to the teambamf website now , and instead is linking to Ziggy's PPCGeeks post.


----------



## 00negative

"wraithdu said:


> I don't think the source of the binaries is really in question here, so much as what to do with them.
> 
> BTW, ihtfp69 pulled his link, which just goes to the teambamf website now , and instead is linking to Ziggy's PPCGeeks post.


Ah sorry I will edit previous post. Thought he still left a version of his own there for use.


----------



## .ZIP

Thanks for this post it worked like a beast I am now running desired kernel on preffered rom. Consider a donate button or i'll have no choice but to send you a cigar via Post office.


----------



## wraithdu

Lol, I'm surprised it took so long for someone to try it out!. Seriously though, no donations etc deserved. Just standing on the shoulders of others with a few adb commands.


----------



## OnlyZuul

Just did this, worked great! Thanks!


----------



## .ZIP

I just realized that m WiFi was broken. I get an "error" i know its the kernel I packed up. What did I miss? Thanks


----------



## wraithdu

Sounds like you missed the /system/lib/modules from the kernel you are packaging.


----------

