I am trying to make a backup (a direct dd image of the partitions of my built-in memory card of my phone to my PC. I am using Linux and my phone is a Nexus 4.
Instead:
Install android-platform-tools
or android-sdk
onto your computer.
Download TWRP to your computer.
Hold the volume down and volume up buttons and turn on your phone to start up the bootloader screen. Make sure your phone is plugged into your computer's USB port.
Boot TWRP by running fastboot boot twrp-3.1.0.0.img
. (No need to flash your recovery partition this way.)
In TWRP, select Advanced, then Terminal, which will open a shell. Type mount
and press [ENTER] to see the partitions. You're looking for the /data
and possibly /sdcard
mounts.
Let's say your /data
partition maps to /dev/mmcblk0p28
. Just run adb pull /dev/block/mmcblk0p28 data.img
on your computer and it will copy the partition. Expect this process to take a while since it is copying the entire partition, regardless of how many files are stored in it.
Requirements: adb must be already installed
From your Linux PC in the folder where boot.img is located type:
$ fastboot boot boot.img
To make an image of the mmcblk0p23 partition type:
$ adb shell 'stty raw && dd if=/dev/block/mmcblk0p23' > ~/userdata.img
Useful Links:
How to you identify the partition of interest: http://forum.xda-developers.com/showthread.php?t=2450045
If stty raw is not used all LF will be translated to CRLF: android.stackexchange.com/questions/69434/is-it-possible-to-cat-a-file-to-an-android-phone-and-dd-to-dev-xxx-on-the-fly-w
How to root phone and use insecure boot.img: www.addictivetips.com/android/root-google-nexus-4-install-clockworkmod-recovery/
Transferring binary data over ADB shell (how to use stty raw): stackoverflow.com/questions/11689511/transferring-binary-data-over-adb-shell-ie-fast-file-transfer-using-tar
Edit: Hongo's answer has fewer steps.
fastboot flash recovery twrp.img
), then you can try fastboot reboot-bootloader
, then select Recovery
. data
partition in mounted. Make sure your system
partition is mounted, as you'll need some executables that reside there. adb
adb
if you haven't already. Connect your phone to your computer by USB cable. Type adb devices
. If you see a device listed, then you're connected.adb forward tcp:33333 tcp:33333
adb shell mount
/dev/block/dm-0
, it's part of a logical volume (LVM) and this is probably not the right way to back it up]adb shell
dd if=/dev/block/dm-0 bs=64k | gzip | nc -l -p 33333
/dev/block/dm-0
with the the device that you found from the mount command, earlier. 33333
with the phone port that you picked above/system/bin/toybox
or /system/bin/busybox
. if=
) and, using a block size of 64k (bs=64k
- you can specify any, or omit this argument entirely, but small values will likely slow the process down. Values larger than 64k will generally not speed the process up), dumps this to stdout
, which is piped into gzip to compress it, then piped into netcat, which is listening (-l
) on port 33333 (-p 33333
). nc localhost 33333 | pv -i 0.5 --size 54g > dm-0.raw.gz
33333
with the computer port that you picked abovedm-0.raw.gz
with any file name54g
with the size of your partition (see below)33333
on the localhost (your computer) and dumps to stdout
, pipes that to pv
, which updates the transfer progress every half second (-i 0.5
) with an estimated size of 54 gigs (--size 54g
- you can omit this argument but it's necessary for the transfer progress to be accurate), then into a file named dm-0.raw.gz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With