How to unpack/repack Boot.img using terminal apk ( for DEV)

share on:

This is a tutorial is all about compiling kernels. It offer 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 post 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 @Modding.MyMind.

I am not responsible for anything you do to your device by using these tool”.

 

Project Requirements:
  1. Android device
  2. Have root ( if you don’t have a rooted phone, you may check Why Root an Android then Root your phone with one click
  3. Have Busybox installed (1.23.1 is recommended)
  4. Terminal Emulator from play-store
  5. Root Explorer from play-store
  6. Your devices boot.img and/or recovery.img
  7. mkbootimg_tools-master.zip
dd if=/dev/block/platform/msm_sdcc.1/by-name/boot of=/sdcard/boot.img >
  1. Step: First pull the Boot.img we are going to work with using dd. Open your terminal and type
 su >

press enter,It will activate root permission on your terminal emulator. then 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 SD-card called boot.img.

2. Step: 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. Step: 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. Step: 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. Step: 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. Step: Open up your terminal emulator app and type

su >

press enter.
7. Step: 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.

 

So How to Unpack My Boot.img?

1. Step: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. Step: So now you have your unpacked boot.img.
3. Step: Now go to your terminal and type

cd bootfolder >

and press enter. We are going into your boot-folder 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 ram-disk for you.
4. Step: So now you have unpacked a Boot.img and also learned how to decompress your ram-disk.

 

How to decompress a ramdisk in lzma format?

Go to  ./mkboot recovery.img workfolder
then cd workfolder/ramdisk
3. Now type:

lzma -dc ../ramdisk.lzma | cpio -i; strings *.ko
  1. Now you will have your lzma compressed ramdisk inside your work-folder

Now we are going to repack your Boot.img

  1. In your terminal emulator 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

 

Cradit: XDA

share on:
Arafat Ikram Shanto

Arafat Ikram Shanto

Just a common man with common thought

2 Comments

Leave a Response

*

code

share on: