Share Android SD card with PC via USB on gingerbread using mass storage device protocol

Android 4 already has MTP (Media Transfer Protocol), but sometimes you need to use android 2.3. We use it for sending SMS notofications - it’s simple and cheap.

To share SD card to both PC and Android, you need a rooted phone and a dirty hack. So here it is:

  1. Enter device console on android device (via ADB, ssh, terminal emulator, etc)
  2. issue “mount” command - it will show you all currently mounted devices.
  3. There you’ll see smth like
    /dev/block/vold/179:1 /mnt/sdcard vfat 
    Remember it.
  4. plug your device into computer, select file transfer mode.
  5. In device console, enter smth like
    mount -r -t vfat /dev/block/vold/179:1 /mnt/sdcard
  6. Your SD card is mounted on your android device in read only mode (-r flag), you are wonderful!

You can probably mount in writable mode but it can be dangerous.

If you need to use this mount often, you can create another mount point (which is always -r connected with SD card), or write a software button which mounts it.

Here’s a sample of my mounting program (works for samsung galaxy mini): Feel free to use and to fork.