None
None

Reputation: 2433

Copy full disk image from Android to computer

I have a smartphone without the possibility to insert an SD-card. I would like to make a dump of the biggest partition (cause I lost files and I'd like to use a dump to recover them).

The partition is 10GB.

I was looking for an ADB command to pull using dd but nothing...

I tried to use Carliv touch recovery with a 32GB USB key by OTG but the USB key didn't mount ... Then I couldn't use dd directly on the phone using Aroma file manager and a terminal emulation.

Upvotes: 59

Views: 151241

Answers (3)

None
None

Reputation: 2433

As said in comment, adb pull /dev/block/mmcblk0 mmcblk0.img worked for me. A "DD image" is only a binary image file of the device.

Upvotes: 55

Nikola
Nikola

Reputation: 147

Run as root:

adb root

Use dd to output content into stdout and write file on your computer:

adb shell 'dd if=/dev/block/platform/msm_sdcc.1/by-name/XXXXXX 2>/dev/null' > XXXXXX.img

Or all (see cat /proc/partitions)

adb shell 'dd if=/dev/block/mmcblk0 2>/dev/null' > mmcblk0.img

Upvotes: 13

user2305193
user2305193

Reputation: 2059

You want to copy a disk from your android device to your computer (preferably on your fastest drive) for faster and lossless analysis/recovery.

This is short step-by-step guide in windows (linux: scroll down) to achieve it using the linux tool dd intended for precise, bit-wise copies of data. Credits go to scandium on xda for the code, see his post for more details.

Prerequisites

Windows:

  1. install cygwin. During install, add netcat (under Net) and pv (under util-linux) packages; the standard install is located in C:\ so make sure you have enough disk space beforehand;

  2. install adb e.g. through Android Studio. Make sure to add adb.exe executable file to the path variable to access it properly (guide).

  3. Open two cygwin consoles/terminals (one sending data, one receiving data) and enter in one of the terminals to enter the device:

    # terminal 1
    adb forward tcp:5555 tcp:5555   # forward data over tcp connection
    adb shell                       # open a connection
    su                              # gain root access
    BUSYBOX=/system/xbin/busybox    # default location for most bb installers
    
    # note: adapt the variable `BUSYBOX` to point to your install directory
    #       the TWRP default is `BUSYBOX=/sbin/busybox` (in case of bricked device)
  1. Decide what partition to copy, the /dev/block/mmcblk0 partition is usually the one containing the data you typically would want.

  2. In the following code, adapt the partition name according to 4. and quickly one after another type in terminal 1 and terminal 2:

    # terminal 1
    $BUSYBOX nc -l -p 5555 -e $BUSYBOX dd if=/dev/block/mmcblk0
    # terminal 2
    nc 127.0.0.1 5555 | pv -i 0.5 > $HOME/mmcblk0.raw    

This saves the partition in the cygwin home directory (in a nutshell: it sends/receives output of dd over a tcp connection)

Look at the files / analysis

  • To mount the partition in Windows you can use (OSFmount).

  • To analyze the files I recommend Active@ Undelete but there are tons of alternatives. With that program you can also directly load all partitions from the file (without mounting it, so step 5 is redundant in this case).

Guide for GNU/Linux users: install netcat and pv (step 1), use the Disks utility to analyze

Upvotes: 22

Related Questions