Tuesday, April 28, 2020

[Tutorial] How to use ADB + root to backup Android device partitions

This is a step by step guide on how to backup an Android phone's firmware / partitions using adb. This covers partitions like boot, recovery, system etc.

Method 1: ADB Method I


  1. Install a root browser (e.g ROM Toolbox lite) and navigate to dev/block/platform . Open each folder in the platform folder till you find a folder named "by-name". Replace "your_folder" in the code below with the name of the folder which contains the by-name folder
  2. Launch ADB and type the code below. Press Enter after each line
    Code:
    adb shell
    ls -al /dev/block/platform/your_folder/by-name
  3. You should get an output of the phone's mount points
  4. Type the code below to dump the partition of your choice

    Code:
    adb shell
    su
    dd if=/yourMountingPoint of=/yourDestination/partitionType
  5. For example

    Code:
    adb shell
    su
    dd if=/dev/block/mmcblk0p9 of=/sdcard/system.img

Method 2: ADB dd 2


  1. Launch ADB and run the command below

    Code:
    adb shell
    cat /proc/dumchar_info
  2. You should have an output like

    Code:
    Part_Name          Size             StartAddr         Type  MapTo                 Region
    preloader    0x0000000000040000   0x0000000000000000   2   /dev/misc-sd           BOOT_1
    mbr          0x0000000000080000   0x0000000000000000   2   /dev/block/mmcblk0     USER
    ebr1         0x0000000000080000   0x0000000000080000   2   /dev/block/mmcblk0p1   USER
    pro_info     0x0000000000300000   0x0000000000100000   2   /dev/block/mmcblk0     USER
    nvram        0x0000000000500000   0x0000000000400000   2   /dev/block/mmcblk0     USER
    protect_f    0x0000000000a00000   0x0000000000900000   2   /dev/block/mmcblk0p2   USER
    protect_s    0x0000000000a00000   0x0000000001300000   2   /dev/block/mmcblk0p3   USER
    seccfg       0x0000000000020000   0x0000000001d00000   2   /dev/block/mmcblk0     USER
    uboot        0x0000000000060000   0x0000000001d20000   2   /dev/block/mmcblk0     USER
    bootimg      0x0000000001000000   0x0000000001d80000   2   /dev/block/mmcblk0     USER
    recovery     0x0000000001000000   0x0000000002d80000   2   /dev/block/mmcblk0     USER
    sec_ro       0x0000000000600000   0x0000000003d80000   2   /dev/block/mmcblk0p4   USER
    misc         0x0000000000080000   0x0000000004380000   2   /dev/block/mmcblk0     USER
    logo         0x0000000000300000   0x0000000004400000   2   /dev/block/mmcblk0     USER
    expdb        0x0000000000a00000   0x0000000004700000   2   /dev/block/mmcblk0     USER
    tee1         0x0000000000500000   0x0000000005100000   2   /dev/block/mmcblk0     USER
    tee2         0x0000000000500000   0x0000000005600000   2   /dev/block/mmcblk0     USER
    kb           0x0000000000100000   0x0000000005b00000   2   /dev/block/mmcblk0     USER
    dkb          0x0000000000100000   0x0000000005c00000   2   /dev/block/mmcblk0     USER
    android      0x0000000080000000   0x0000000005d00000   2   /dev/block/mmcblk0p5   USER
    cache        0x0000000010000000   0x0000000085d00000   2   /dev/block/mmcblk0p6   USER
    usrdata      0x000000030ce00000   0x0000000095d00000   2   /dev/block/mmcblk0p7   USER
    bmtpool      0x0000000001500000   0x0000000001500000   2   /dev/block/mmcblk0     USER
  3. If you wish to dump recovery.img for example, take note of the recovery line

    Code:
    recovery     0x0000000001000000   0x0000000002d80000   2   /dev/block/mmcblk0     USER
  4. Convert the Size and StartAddr values from Hexadecimal to Decimal then divide by 4096 (which is the Block Size)
    Run the command below

    Code:
    #mount -o ro,remount /emmc@android /system
    dd if=/dev/block/mmcblk0 bs=4096 skip=StartAddr count=Size | gzip >  /data/local/tmp/recovery.img.gz
  5. For Recovery in this example, it'll be

    Code:
    #mount -o ro,remount /emmc@android /system
    dd if=/dev/block/mmcblk0 bs=4096 skip=11648 count=4096 | gzip >  /data/local/tmp/recovery.img.gz
  6. Check your device for the dumped image

Method 3: ADB + ROMdump.zip method


  1. Setup ADB
  2. Download ROMdump
  3. Extract the file named "Install" from the ROMdump zip file and copy it to the same location as adb.exe
  4. Enable USB debugging on the phone (Settings > Developer > Tick USB Debugging) and connect the phone to PC
  5. Launch adb.exe (Open the adb folder > Hold Shift button > Right-click on any empty space > Select Open Command Window here)
  6. In the command window, type the following commands and press Enter after each:
    Code:
    adb devices
    adb push install /data/local/
    adb shell chmod 04755 /data/local/install
    adb shell /data/local/install
  7. Wait till pushing is complete
  8. Toggle Wi-Fi On then Off or Off then On then Off (depending on its current state)
  9. Type the command below in the command window then press Eenter
    Code:
    adb shell romdump
  10. Wait for the process to be complete and you'll have your ROMdump
  11. You'll find your files in a folder named romdump in the root of the SD card

Method 4: Terminal + ROMdump.zip method


  1. Ensure the phone is rooted (see https://blog.hovatek.com/how-to-root-and...ithout-pc/ )
  2. Install Android Terminal Emulator
  3. Download ROMdump
  4. Extract the file named "Install" from the ROMdump zip file and copy it to the root of the SD card (as in copy directly and not into any folder)
  5. Launch Terminal Emulator and type the following commands then press Enter after each
    Code:
    su
    cat /sdcard/install >/data/local/install
    chmod 04755 /data/local/install
    /data/local/install
  6. Wait for the process to complete
  7. Toggle Wi-Fi On then Off or Off then On then Off (depending on its current state)
  8. Type the command below in Terminal Emulator then press Enter
    Code:
    /system/bin/romdump
  9. Wait for the process to complete and you're done
  10. You'll find your files in a folder named romdump in the root of the SD card

Method 5:  ADB Method II


  1. Note: Only use this method for Boot and Recovery images, not for System image
    Also, you can use Terminal Emulator for this method instead of ADB
  2. Setup ADB
  3. Launch adb.exe (Open the adb folder > Hold Shift button > Right-click on any empty space > Select Open Command Window here)
  4. In the command window, type the following command then press Enter
    Code:
    adb shell
  5. If you're using Terminal emulator instead of ADB then type
    Code:
    su
    and Select Grant when prompted
  6. Type
    Code:
    cat proc/mtd
    or
    Code:
    cat proc/emmc
    depending on your phone type then press Enter
  7. You'll get an output similar to this:
    Code:
    dev:    size   erasesize  name
    mtd0: 000a0000 00020000 "misc"
    mtd1: 00480000 00020000 "recovery"
    mtd2: 00300000 00020000 "boot"
    mtd3: 0fa00000 00020000 "system"
    mtd4: 02800000 00020000 "cache"
    mtd5: 093a0000 00020000 "userdata"
  8. To dump the recovery image to your SD card, take note of the first word of the line which says “recovery” in the end. It is ‘mtd1’ in this example. Now use the command below, replacing ‘mtd1’ with the term that applies in your case, if different then press Enter:
    Code:
    dd if=/dev/mtd/mtd1 of=/sdcard/recovery.img bs=4096
  9. For boot image in this example, type the command below then press Enter
    Code:
    dd if=/dev/mtd/mtd2 of=/sdcard/boot.img bs=4096
  10. You should have your partition images dumped to the root of your SD card

Method 6: AIO Flasher Method


  1. Download AIO Flasher
  2. Launch it
  3. Enable USB debugging on the phone (Settings > Developer > Tick USB Debugging) and connect to PC via USB cord
  4. Go to The Backup / Restore tab
  5. Click on Install RomDump and ait till the log by the right shows
    Code:
    Pushing Romdump...
    Installed.
  6. Click Dump!
  7. Once complete, You'll find your files in a folder named romdump in the root of the SD card

Important Notice
A box / dongle can enable you easily achieve this without root

No comments:

Post a Comment