I accidentally removed my whole file system on my phone .I tried to recover my files with my linux pc using photorec program .but photorec only can detect directly connected devices to the system.my phone only makes connection with mtp and ptp.if i can mount my phone to my pc as a ums(usb mass storage) photorec will detect my device.so is there any way to mount my phone as ums?

phone OS

Android Lollipop 5.02

phone model

LG G3 Beat (a.k.a mini) D723tr

pc os

Linux mint rosa


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
  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. Write :wq and press enter
  12. chmod 777 /data/local/tmp/usb_mount.sh
  13. sh /data/local/tmp/usb_mount.sh

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

Comment if you face any issues.

  • I have a question... from where did that script at point 8 pop up?
    – Grimoire
    Aug 25 '16 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
    Aug 25 '16 at 16:09
  • 1
    @GokulNC Good explanation.. Go ahead and edit my answer.. Aug 25 '16 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.