I am trying to mount an .img file from my internal storage as Usb Mass Storage.

There is an Android App named DriveDroid which does exactly what I wanted. I tested with this app and the app successfully mounted an .img file as USB Mass Storage.

But I am unable replicate the same manually.

Anybody having any information on how to mount .img as UMS ?

Phone Details:
  Model : Moto G 2013
  Device Name : falcon
  Rooted : YES
  OS : CyanogenMod 13.0



Here are the Terminal commands:

echo /sdcard/your_image.img > /sys/class/android_usb/f_mass_storage/lun/file
echo 1 > /sys/class/android_usb/f_mass_storage/lun/cdrom
setprop sys.usb.config mass_storage

(The location of LUN may vary for some devices, you can manually check/search for it even using File Explorer..)

If above commands fail, you might want to disable SE Linux by setenforce 0 command to set it to Permissive, and try again..

  • I think I just used your xda post to install busybox.. :D Aug 25 '16 at 12:56
  • What XDA post? ;)
    – Gokul NC
    Aug 25 '16 at 13:21
  • I remember you from somewhere but I can't remember where I saw your post/blog/something Aug 25 '16 at 13:51

DriveDroid is developped by FrozenCow, and here are the commands he suggests to reproduce DriveDroid functionality without installing the software:

echo 0 > /sys/class/android_usb/android0/enable
echo MYISO > /sys/class/android_usb/android0/f_mass_storage/lun/file
echo mass_storage > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable

These commands are quoted from his own comment in this issue, see the third comment "The following can be used to test the functionality".

In the background, DriveDroid relies on an open Linux kernel feature called Mass Storage Gadget (MSG). You can find documentation about this feature here and there in order to have a better understanding of its possibilities.

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.