Post Reply

Mounting Internal Storage as a USB Mass Storage Device and Recovering Data

OP CleverCoder

9th August 2014, 10:09 PM   |  #1  
OP Junior Member
Thanks Meter: 0
6 posts
Join Date:Joined: Sep 2009
CleverCoder's Guide to Mounting Android’s Internal Storage As A Mass Storage USB Device

I found inspiration from this guide:
His process did not work exactly, but by changing the “lun” to “lun0” and the path to the “android_usb” device, I was able to get this to work with my rooted Samsung Note 10.1. The instructions below were verified on my Note 2.

I was motivated to find this solution after I accidentally deleted my daughters world that she worked so hard to create in Survivalcraft. Ultimately, I wasn’t able to recover her world, but I learned a lot in the process. Enjoy!

  1. Boot into recovery mode (Usually holding volume (and home) down while powering up). I find the Wiki on CyanogenMod to be helpful to find device-specific bootloader instructions.
  2. Invoke a root shell using ADB: “adb shell" (Note: This assumes you have the Android SDK installed and /platform-tools are in your PATH)
  3. Find the /data partition, determine the block device that corresponds to it:

    mount | grep /data

    /dev/block/mmcblk0p16 on /data type ext4 (rw,seclabel,relatime,user_xattr,barrier=1,data=or dered)

  4. Make a note of the block device name. In my case, it's "/dev/block/mmcblk0p16". Unmount the /data partition to allow mounting as a mass storage device:
    umount /data
  5. Locate the “mass storage” device LUN entry. (In my case, it was ..\lun0 rather than ..\lun):
    find /sys -name lun*


    In this case, we want to make a note of the entry with "f_mass_storage" in it. This is the entry that corresponds to a USB Mass Storage device.
  6. Map the block device to the mass storage logical device LUN “file”. Note, this will be a file called “file” within the LUN folder. For example:
    For example:
    echo /dev/block/mmcblk0p16 > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun0/file
    Note: the ADB shell appears to wrap at around 80 characters, making it look like the line is split.
  7. Reconfigure the USB device in “mass storage” mode. This has to be done in one command, since it will terminate the ADB connection. Also, the path varies to the “android_usb” device. It may be:
    You can use "find /sys -name *android0*" to help narrow the options. I believe either entry will work. YMMV

    On my Note 2 the following worked:
    echo "echo 0 > /sys/devices/virtual/android_usb/android0/enable && echo \"mass_storage,adb\" > /sys/devices/virtual/android_usb/android0/functions && echo 1 > /sys/devices/virtual/android_usb/android0/enable" >
    sh &
    This should terminate the ADB connection and cause a new USB device to appear, representing the /data volume mounted as a mass storage device.

At this time, the block device associated with the /data partition should show up as a USB mass storage device on your computer. I verified this with OSX. OSX did not support the ext3/4 filesystem, however, Unix utilities that support it will work.

Recovering Files

Once the device is mounted on your host machine, you can use PhotoRec ( to recover files. It performs a file signature based recovery, is very powerful, and works with any file you can think of. It’s also easy to add support for your own file types.

I hope this helps others.
- Sean
Last edited by CleverCoder; 9th August 2014 at 10:16 PM. Reason: Small typos
9th October 2014, 11:49 PM   |  #2  
Junior Member
Thanks Meter: 0
16 posts
Join Date:Joined: Mar 2011
Have anyone tried it?
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Top Threads in Android General by ThreadRank