HOW TO PULL/EXTRACT BOOT, RECOVERY, SYSTEM IMG VIA ADB

Here's a short tutorial on how you can pull those stock IMG from your device using adb. This is quite helpful to those who haven't installed a custom recovery.img like TWRP yet and wish to extract the stock recovery.img so they can go back later on to be able to get OTA updates if they wish to.

This tutorial will be used for Asus Zenfone 2 Laser 5.5s ZE550KL so if you happen to have a different device try to follow procedure if it will work out.

note: Root access is required

OTHER DEVICES
To give you some idea on some devices that may work is the use these commands in adb command window:
  • adb devices (hit enter key)
  • adb shell (hit enter key)
  • su (hit enter key)
  • cat /proc/mtd (hit enter key)

It will give you this similar results with different mtd as shown:

dev: size erasesize name 
mtd0: 00040000 00020000 "misc"
mtd10: 00500000 00020000 "recovery
mtd12: 00280000 00020000 "boot" 
mtd13: 04380000 00020000 "system" 
mtd14: 04380000 00020000 "cache" 
​mtd15: 04ac0000 00020000 "userdata"

To pull of those needed IMG like recovery

Once you see it's LOCATION in which in this sample is in mtd10

​type:

cat /dev/mtd/mtd10 > /sdcard/mtd10.img 

or 

cat /dev/mtd/mtd10 > /sdcard/recovery.img 

Go now and check from your sdcard after extracting if you have your recovery.img file that was saved.

Take note that this not apply to all devices.

Asus Zenfone 2 Laser 5.5s ZE550KL
This time for our device Asus Zenfone 2 Laser 5.5s have a different way to locate those IMG.

Simply connect device to your computer and type the following codes:
  • adb shell
  • cat /proc/partitions
This will give you a list of mmcblk numbers but you have no clue which one is your boot, recovery, system etc.
cat /proc/partitions
cat /proc/partitions
Now from your device using a root explorer app navigate to /dev/block/platform/ and navigate to the folder that will contain a folder with "by-name"
/dev/block/platform/
use_root_explorer_app
Once you know the location of "by-name" folder simply follow the sequence of folder location
by-name_folder
Depending on how many sub folders before you reach the "by-name" folder use this code for your adb command

ls -al /dev/block/platform/???/???/by-name

From your command window type the following after you already know the location, for this sample "by-name" folder was found under folder 7824900.sdhci and the latter under soc.0 folder

  • adb shell
  • su
  • ls -al /dev/block/platform/soc.0/7824900.sdhci/by-name

You will get the following list and just search which mmcblock your IMG needed is located
for boot.img located at mmcblk0p37
mmcblk0p37_boot.img
mmcblk0p37
mmcblk0p38__recovery.img_mmcblk0p45_system.img
mmcblk0p38__recovery.img_mmcblk0p45_system.img
Your recovery.img and system.img located at mmcblkp38 & mmcblkp45 respectively. Once you know the block you can now extract with this command:

cat /dev/block/mmcblk0p38 > /sdcard/recovery_pull.img

Do the same with boot and system by replacing the mmcblk number and naming the files for proper distinction.

Navigate to your sdcard folder to see your extracted IMG files. Since I moved the file to my microsd card manually this is now my recovery_pull.img file
recovery_pull.img_extracted
Now you can flash the TWRP recovery to your device and start creating your back up ROM. Be reminded that this was tested for Zenfone 2 Laser 5.5s ZE550KL, you may wish to try if your device has the same set up of partitions.

Download codes (here)

Enjoy!

1 comment:

  1. Thank you for this contribution to the internet. Useful technique.

    ReplyDelete

#