[Android Software/Hacking General [Developers Only]] skulldreamz:
This is a tutorial I've decided to put together as I'm learning to compile kernels. It will cover unpacking and repacking a boot.img and/or recovery.img, and also touch on unpacking the ramdisk after we have unpacked the boot.img This tutorial will only focus on executing this on a android device using the terminal emulator app but of course you could use these tools on a PC in a adb shell.

This would not be possible without the hard work of xda member [MENTION=6367467]Modding.MyMind[/MENTION]. I am not responsible for anything you do to your device by using these tools.

What you will need

1. Android device

2. Have root

3. Have busybox installed (1.23.1 is recommended)

4. Terminal Emulator app

5. Root Explorer app

6. Your devices boot.img and/or recovery.img

7. mkbootimg_tools-master.zip (download below)

https://www.dropbox.com/s/fiat0zrf2f533uq/mkbootimg_tools-master.zip?dl=0

DIRECTIONS

1. Let's pull the boot.img we are going to work with using dd. Open your terminal and type su > press enter. Type dd if=/dev/block/platform/msm_sdcc.1/by-name/boot of=/sdcard/boot.img > press enter and now you should see a file on your sdcard called boot.img

2. Place the zip file on the root of your internal sdcard and extract it. You will see a folder called mkbootimg_tools-master and inside that folder you will see 2 folders. One called ARM and one called README.md Now we are going to copy the ARM folder to data/local/tmp and paste it inside of the tmp folder.

3. Now we need to go the ARM folder that you just copied inside tmp and set the permissions to 0777 (rwxrwxrwx) and also set the same permissions for each file inside the ARM folder.

4. Now go inside the ARM folder and copy the bash file to system/xbin and set the permission to chmod 0755 (rwxr-xr-x)

5. Ok now copy the boot.img file that we pulled onto your sdcard inside the ARM folder and leave the permissions for that file 0666 (rw-rw-rw-)

6. Open up your terminal emulator app and type su > press enter

7. Now we are going to change directories to the ARM folder which we want to be in by typing cd data/local/tmp/ARM > press enter

########################################

Now to unpack your boot.img

1. Type ./mkboot boot.img bootfolder > press enter and you will see the magic happen. It will automatically create a folder called bootfolder which is your project folder and you can name it whatever you like but I like to call it bootfolder and if I was unpacking a recovery.img I would call it recoveryfolder

2. So now you have your unpacked boot.img.

3. Now go to your terminal and type cd bootfolder > and press enter. We are going into your bootfolder now because that is where your ramdisk.gz is located and we are now going to decompress your ramdisk by typing gunzip -dc ramdisk.gz | cpio -i > and press enter and it will decompress your ramdisk for you.

4. So now you have unpacked a boot.img and also learned how to decompress your ramdisk.

########################################

How to decompress a ramdisk in lzma format

1. ./mkboot recovery.img workfolder

2. cd workfolder/ramdisk

3. Now type lzma -dc ../ramdisk.lzma | cpio -i; strings *.ko

4. Now you will have your lzma compressed ramdisk inside your workfolder

#######################################

Now we are going to repack your boot.img

1. In your terminal type cd .. > and press enter so you will move back 1 directory into your ARM folder.

2. Now to repack you are going to type ./mkboot bootfolder boot.img > and press enter and that will repack your boot.img for you

*wherever you saw me type a > don't ever type that as I was just showing that you are done the command or syntax and your are ready to press enter

Source code https://github.com/ModdingMyMind/mkbootimg_tools/commit/6c44267b4a8a43504c870678c68df6a31b8e2f18

Screenshot - https://www.dropbox.com/s/se171tzgnf6wp0q/Screenshot_2015-03-12-02-49-50.png?dl=0

Screenshot - https://www.dropbox.com/s/5bzt8p6l2ltosl6/Screenshot_2015-03-12-02-50-04.png?dl=0

Thanks to [MENTION=2932079]leonardoafa[/MENTION] for being a great help & friend