• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root [Without PC] Unpack, Edit, Repack boot.img

M

ModdingMyMind

Guest
Hello friends, I'm back again with something I wish to share with you all. I have compiled three files to work flawlessly for ARM devices which will allow users to unpack, edit, and repack their boot.img without the use of a PC and all straight from their device.

---unmkbootimg, mkbootfs, mkbootimg---

https://github.com/ModdingMyMind/boot_manipulation
Hey guys, since I have made this thread a while back there has been a LOT of changes made to the resource. For starters, it is now a multi call binary. In addition, I have updated mkbootfs for better support, mkbootimg.c has dt support, unmkbootimg.c has dt support, bootimg.h has dt support, as well as adding dtbtool, and dtc. Lets not also forget about lz4 for those whos ramdisks are not gz compressed. I am continuously making changes to the source and the op attachment will not be kept up to date. To stay up to date you will need to build the multi call binary from the source provided by the link above. Just simply run: make multi.



Note:
-- The mkbootimg binary is based upon the AOSP with some added modifications to work in conjunction with unmkbootimg.
-- The unmkbootimg binary is based on the original mkbootimg source but with reverse engineering to compliment its helpful use in extraction and thus providing the needed command to rebuild properly.
-- The mkbootfs binary is based on the source provided within the dsixda kitchen to insure the proper structural repacking of the ramdisk, etc.


Requirements:
-- BusyBox (cpio, gunzip and gzip is mandatory)
-- /System Write Permissions (Does not need to be a modified kernel)
-- Terminal Emulator
-- ES File Explorer (or similar)
-- Hex Editor (or use of DD)

-- Unzip boot_manipulation.zip on your device and copy the three files over to /system/bin. Those three files inside the .zip will be named unmkbootimg, mkbootfs and mkbootimg.
-- EDIT: I have included a flashable zip for these files.
-- Set permissions to rwxr-xr-x (755) on each binary. Note: The flash zip does this already.

-- Open up your android terminal emulator.

-- Now go ahead and pull your boot.img from your device (or use another one if you wish). Here is an example:
Code:
root@android:/ # [COLOR="Red"]dd if=/dev/block/mmcblk0p20 of=/data/local/tmp/boot.img[/COLOR]
dd if=/dev/block/mmcblk0p20 of=/data/local/tmp/boot.img
32768+0 records in
32768+0 records out
16777216 bytes transferred in 1.496 secs (11214716 bytes/sec)
root@android:/ #

-- Open up your boot.img with the Hex Editor and look for: ANDROID!. Remove everything before it so that the ANDROID! header is the first to be read then save it over top of the boot.img. NOTE: This is only required if you are using a stock boot.img. Here is an example:
Code:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000  [COLOR="red"]A5 F0 BA B7 B0 43 E3 F8 3C E1 63 55 AE 75 C6 69
 

Attachments

  • boot_manipulation.zip
    16.7 KB · Views: 1,458
  • flash_boot_manipulation.zip
    140.7 KB · Views: 1,301
I have an unmkbootimg that is compiled for arm devices now. Gonna mess with it and see what's up :). My goal is to make every need of using linux to be properly done on our devices. I'm always on the go so without a pc I have to find ways to do them on my phone. This is a very good start lol.
 
  • Like
Reactions: irishobo
Upvote 0
OP has been updated. I have included an additional binary called mkbootfs to work in conjuction with the other two given the necessary structural building properties of the boot.img. I have tested this on A LOT of boot.img's and all have been successful. I have also updated the instructions for using these binaries on your android device. Enjoy.
 
Upvote 0
Each time I try to run this on my rooted LG G2 I get an error...
u0_a92@vs980:/ $ cd /sdcard/download
u0_a92@vs980:/sdcard/download $ unmkbootimg -i boot.img
/system/bin/sh: unmkbootimg: can't execute: Permission denied

You aren't following my instructions lol. You can't run them on the sdcard because the sdcard is a vfat format which doesn't allow such processing to be completed. That's why I mentioned to place the three binaries in /system/bin and chmod them to 755, then place the boot.img or recovery.img in to /data/local/tmp.
 
Upvote 0
You aren't following my instructions lol. You can't run them on the sdcard because the sdcard is a vfat format which doesn't allow such processing to be completed. That's why I mentioned to place the three binaries in /system/bin and chmod them to 755, then place the boot.img or recovery.img in to /data/local/tmp.

I also had the error when following your instructions. It was the permissions for the 3 files that needed fixed.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones