
First you need a working adb setup, running as root. If you don't want to use an external SD card, you can also dump the partition directly to PC. To create the dump: ~# dd if=/dev/block/bootdevice/by-name/userdata of=/path/to/ext_sdcard/data.img An external SD card with larger capacity is needed. Since the userdata partition is the largest partition (all other partitions are hardly using 5GB out of total storage), you can't dump it to your internal memory. Once the block device is known, you can use the dd command from:
To prevent any data loss, it's recommended to create a dump when the partition is not mounted i.e. dm-crypt decrypts the block device to /dev/block/dm. See some relevant explanation in my answer to Cross-platform compatible encryption of SD-card for Android. If your /data partition has Full Disk Encryption (FDE) you need to decrypt it before exposing to UMS because decrypting Android's FDE on PC is near to impossible in most cases due to hardware-backed encryption.
Or by hit and trial: ~# ls -d /dev/*/by-name You can find all block devices or by-name directory using find command: ~# find /dev -type b For MediaTek ( MTK) and other SoCs, the path is slightly different. On Qualcomm devices, it's located at /dev/block/bootdevice/by-name/userdata (symlink). If you have root access, you can do so from mounted partitions: ~# mount | grep 'on /data' In order to access the userdata partition, you need to find its block device.
Mount the filesystem (if required) in recovery mode (or on PC) only with ro,nodiscard options. Don't install data recovery apps on device, it can do more harm than good. Switch off phone to make sure the deleted data isn't overwritten. And you haven't done a factory reset on encrypted /data partition. Your deleted data hasn't been TRIMmed or discarded. In short, recovery is more or less possible only if ( 1): All require root access.īut first of all, see this answer to make sure your data is recoverable. You can do that in multiple ways described below. If a file is deleted from /data, you need to create a dump of data partition, not that of root directory. Is it possible to create an image (.img or something similar) of the root directory. there was a file in the /data directory which I need. data/media/0 is the directory that we see as /sdcard or /storage/emulated/0 through emulation. This partition contains all user apps, their data (settings, databases, caches, temporary files etc.), system apps' data and all other configurations we make through Settings. /data directory is a mountpoint, where largest partition, usually named userdata is mounted. On newer devices with system-as-root, system partition is mounted at root /.
When device is powered on, it's again extracted from initramfs that lives in boot partition along with kernel. Root directory / of Android devices is a read-only pseudo (temporary) filesystem ( rootfs) that lives in RAM and is vanished when device is powered off.