github email
USB mass storage mode in ICS
Mar 29, 2012
2 minutes read

You’ve might know by now that UMS in Android 4 is missing. And that Google has choosen MTP (a Microsoft protocol) to replace it. That’s not exactly true.

If you have a Nexus phone, there’s a techical reason for not having UMS. It’s internal storage is one large partition, and it’s used by both apps and as a data storage place. UMS requires that the exported volume is not used by anything else when it’s mounted on another machine. But if for example you have a Nexus S, which has a separate sd partition, it actually has and supports UMS perfectly.

Now, if you happen to run e.g. CM9 or AOKP on a Galaxy SII, then you might be struggling with MTP when you don’t really have too (MTP really sucks on linux). Sure, when you plug it in USB, there’s no popup to switch to UMS, but it’s actually there.

UMS is a linux kernel thing. Lookup for ‘USB Gadget’. Even though the ‘frontend’ part is missing from ICS (in CM9 at least, which follows Nexus AOSP sources), USB Gadget functionality is present at kernel level. All you have to do, is to instruct the phone to use it.

So, connect your phone with adb and execute (as root) the following:

{% codeblock %} setprop persist.sys.usb.config mass_storage,adb echo /dev/block/vold/259:3 > /sys/devices/platform/s3c-usbgadget/gadget/lun0/file {% endcodeblock %}

Your internal storage should then popup to be mounted as UMS in your host machine. I don’t have an external sd card on my phone, but the process should be similar for it, by replacing the correct block device and using lun1 as target.

This setting will stay there untill you reboot. Technically, as soon as you unmount and unplug the phone from the computer, you should clear the lun0/file target, but I haven’t experience any problems with this.

Different devices should have different lun/file’s. Try looking around in your system under /sys/devices/.

Update: Seems that this change: http://review.cyanogenmod.com/#change,14451 will make the above post obsolete (haven’t tried it yet).


Back to posts