B2G/USBMassStorage

From MozillaWiki
< B2G
Revision as of 17:36, 25 May 2012 by Dhylands (talk | contribs) (Created page with "This page describes the USB Mass Storage feature in B2G. == Overview == USB Mass Storage (aka UMS) [http://en.wikipedia.org/wiki/USB_mass-storage_device_class] is a block b...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page describes the USB Mass Storage feature in B2G.

Overview

USB Mass Storage (aka UMS) [1] is a block based protocol.

UMS allows a portion of the phone to shared on the PC, when the phone is plugged into the PC via USB cable. As UMS is block-based such, it requires "ownership" of the filesystem being shared. In technical terms, this means that only the contents of an entire partition may be shared.

Terminology

Android has the notion of internal and external SD cards. The internal SD card is really a virtual thing and typically corresponds to a directory tree named /sdcard. Android apps typically store their data in a directory tree called /data. The external SD card is optional, and not all phones have it. For the ones that do, it corresponds to a physical SD card, and can typically be found in /sdcard/external_sd.

History

Prior to Android Honey Comb (HC), UMS was the common way to share data when plugging your phone into your PC. However, requiring that the entire partition be shared lead to people running out of space in the sdcard partition while lots of space remained in /data or vice-versa. With HC and ICS, Android introduced a new way of sharing information called Media Transfer Protocol (MTP), which is a file based protocol.

With the advent of MTP, it is now possible to have /data and /sdcard both exist in the same partition.

UMS is still supported under ICS, but practically isn't usable on all phones.

UMS support on various phones
Phone /sdcard format External SD Can Use UMS? Notes
Samsung Galaxy S II vfat y y
Google Galaxy Nexus S vfat y y
Google Galaxy Nexus ext4 n n Can only use MTP


Enabling UMS

The current B2G builds disable UMS by default and enable MTP. So in order to use mass storage, you'll need to enable it manually. To enable UMS temporarily (until the next reboot):

adb shell setprop sys.usb.config mass_storage,adb

To enable UMS permanently (or until you do a clockworkmod restore):

adb shell setprop persist.sys.usb.config mass_storage,adb

In either case, it's VERY important that mass_storage,adb have no spaces before or after the comma, and that they be in exactly that order (i.e. adb,mass_storage won't work).

To revert to using mtp, replace mass_storage,adb above with mtp,adb

How it works

UMS will only activate once the phone is unlocked, and the Settings->Storage->USB Mass Storage Enable setting is enabled. Once activated, it will stay activated until the usb cable is unplugged or the setting is disabled.

How it manifests itself on the PC will vary depending on the OS. Under ubuntu 12.04, it will show up in Nautilus under Devices: