I accidentally removed my whole file system on my LG G3 Beat (a.k.a mini) D723tr running Android 5.0.2 Lollipop. I tried to recover my files with my Linux Mint (Rosa) PC using PhotoRec program, but PhotoRec can only detect directly connected devices to the system. My phone only makes connections with MTP and PTP. If I can mount my phone to my PC as a UMS (USB mass storage), PhotoRec will detect my device.

Is there any way to mount my phone as UMS?


1 Answer 1


Follow these steps to mount your /data partition as Mass Storage:

  1. Boot to recovery
  2. mount | grep /data
    (Note down the device file /dev/block/...)
  3. umount /data
  4. find /sys -name lun*
    (Note down the URL containing f_mass_storage)
  5. adb shell
  6. su
  7. cd /data/local/tmp
  8. vim usb_mount.sh
  9. Press "i" key to enter Insert Mode
  10. echo 0 > /sys/class/android_usb/android0/enable
    echo [Previously noted down device file] > [Previously noted down URL]/file
    echo mass_storage > /sys/class/android_usb/android0/functions
    echo 1 > /sys/class/android_usb/android0/enable
  11. Press "Escape" key to go back to Command Mode
  12. Write :wq and press Enter to save and quit
  13. chmod 777 /data/local/tmp/usb_mount.sh
  14. sh /data/local/tmp/usb_mount.sh

This should disconnect and reconnect your device as USB Mass Storage.

  • I have a question... from where did that script at point 8 pop up?
    – Grimoire
    Commented Aug 25, 2016 at 14:58
  • 2
    @DeathMaskSalesman That's not an existing script, he's creating that script using vim, then then at step 9, enters input mode and at step 10, enters the contents of the script . At step 11, he saves(writes) the file and quits vim. (Check the vim Documentation if you're not clear.) Well yeah, that would have been comfortable to read if the answerer has included all these with the explanations in the same point.
    – Gokul NC
    Commented Aug 25, 2016 at 16:09
  • 1
    @GokulNC Good explanation.. Go ahead and edit my answer.. Commented Aug 25, 2016 at 16:35

You must log in to answer this question.

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