0

I have connected my rooted Mi3 android phone to Ubuntu 14.0.4 using jmtpfs. I am using ~/Desktop/phone as my mount point. I am able to browse the Android device using Nautilus.

Now I want to recover the files from my phone because I have done a factory reset. I am using the dd command to make a clone of the storage of the phone. When I try to do this I get the following error:

:~/Desktop$ sudo sh -c "dd if=~/Desktop/phone of=/media/sf_phone_recovery/image"
dd: failed to open ‘~/Desktop/phone’: Permission denied

Is it because the phone has root priviliges?

:~/Desktop/phone$ ls -l
total 0
drwxr-xr-x 29 root root 0 May 19 4441318 Internal storage

I have also tried Foremost to recover files but it takes forever to run. Have important files on my phone. Help needed asap.

This is the output of lsblk:

:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0  14.2G  0 disk 
├─sda1   8:1    0   8.3G  0 part /
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0   5.9G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom

I am running Ubuntu using VirtualBox on Mac OSX Yosemite.

This is the discussion of this question at askUbuntu.com link

EDIT: There is another method for recovering your data from an Android phone that does not require access to a PC elaborated here. It involves installing an Android terminal and using the dd command to clone the required storage block of internal memory to a SD card or a pen drive (connected to your phone via a USB OTG cable).

2
  • Not a good idea you received here. They should've told you to flag that question for migration here. Now you ended up with cross-posting.
    – Firelord
    Jul 25, 2015 at 15:58
  • Apart from that: since when is it possible to dd a mapped network drive? dd IMHO requires "physical" access to the partition, which MTP explicitly does not offer (that was one reason why Android switched from UMS to MTP, to be able to access the storage from "both ends" simultaneously). Just checking: You've already got that answer here. We can't tell you differently – so asking until you get the answer you'd like to hear doesn't work ;)
    – Izzy
    Jul 25, 2015 at 16:16

1 Answer 1

2

Short answer: a complete copy of your phone over dd can't be done.

Explanation: Normally when you access a file, your file system driver will parse the folder hierarchy, translate it to an inode, locate the sector on which the file is stored, the metadata is parsed and the file is read. MTP does things differently: your computer sends a request to the device to get file X, your device will parse the directory structure, parse the metadata, locate the sector/cell on the storage device, read the file and then send the data back over MTP.

dd will make a copy of the blocks that are on the storage device itself. Therefore you can copy files and entire partitions because they are blocks of data on the disk. Directories are stored on the disk but they aren't real regions of disk space, they're more like references so files can indicate "I'm part of this folder". Therefore you cannot do a block copy of a directory. Because you cannot do a block copy of a directory, copying the entire storage device of your Android phone over MTP is not possible.

But there is hope: if your device software allows it, you might be able to mount your device as a USB storage device. This will directly attach the storage partition to your computer, allowing you to make a backup using a command like dd if=/dev/sdb of=~/backup_file.

Alternatively, because you have root you could enable Developer Mode on your Android device and then execute the following command after installing the ADB tools (sudo apt-get install android-tools-adb):

adb shell su -c "dd if=/dev/block/mmcblk0" > ~/full_phone_backup.image

This will make a copy of everything on the storage device. It will run for quite some time. I never reached more than 20MB/s over ADB, so it would take 64000/20=3200 seconds at max speed to copy a 64GiB device. After the copy has finished you can run your file recovery software over full_phone_backup.image to get any files back from the system.

7
  • when I run this command adb shell su -c "dd if=/dev/block/mmcblk0" > ~/full_phone_backup.image I get error: device not found
    – user424
    Jul 25, 2015 at 17:56
  • Did you enable developer mode on the phone? Do you get a command line shell if you type in adb shell? "device not found" usually means that the device was not connected to/recognized by the OS.
    – gertmenkel
    Jul 25, 2015 at 17:58
  • No I get the same error error: device not found when I run adb shell. I can explore the device using Nautilus on Ubuntu 14.0.4. I am running the OS in virtualbox, thus the OS is brand new. Are there any dependencies that I need to install for the terminal to detect the device.
    – user424
    Jul 25, 2015 at 18:18
  • Did you enable devoper mode on your phone? This can be done via Settings->Device information and then tapping the field called "build number" seven times. After that, reconnect your device. Then try running adb shell again.
    – gertmenkel
    Jul 25, 2015 at 18:20
  • Yes I did enable developer mode and my phone is also rooted
    – user424
    Jul 25, 2015 at 18:28

Not the answer you're looking for? Browse other questions tagged .