Is the Ubuntu phone filesystem mountable via a usb connection?

Is the Ubuntu phone filesystem mountable in Linux via a usb connection?

Is there reason to believe this feature is here to stay? For me rather than full desktop/phone convergence, I'd be happy with being able to use my phone as the place I store all my essential data (as in a usb stick) and then use it on my phone or share it with my laptop whenever I need to.


Ubuntu Touch lets you access the file system via the MTP protocol, but does not support USB Mass Storage mode. In this respect, it is similar to newer Android devices and is unlikely to change. Out of the box, you should be able to access files on the phone using any GVFS aware application.

There is a good reason why many smart devices have been moving away from mass storage mode as a way of performing file transfer: mass storage mode involves exposing a block device, while MTP exposes a file system.

Unless a file system is specially designed, only one OS should access the underlying block device at a time. FAT is not designed for this use case, which is why older Android phones that supported mass storage mode would unmount the SD card before making it available over USB.

In contrast, with MTP the phone is the only thing accessing the underlying block device, and the connected computer instead makes file system level requests over USB (e.g. list directory, download or upload a file, etc). This means you can continue to use the device while it is connected.


On BQ E5 Ubuntu Edition with Ubuntu Touch 15.04 (r4) I can unmount the external sdcard and switch the usb-port to mass storage mode with the script massStorage.sh and switch the usb-port back to mtp with the script mtp.sh.

Content of sript massStorage.sh:

#!/bin/sh

echo 0 > /sys/class/android_usb/android0/enable
cp /sys/class/android_usb/android0/functions /tmp/massStorageFunctions
echo mass_storage > /sys/class/android_usb/android0/functions
umount /dev/mmcblk1p1
echo /dev/mmcblk1 > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file
cp /sys/devices/virtual/android_usb/android0/f_mtp/device/idVendor /tmp/massStorageVendor
cp /sys/devices/virtual/android_usb/android0/f_mtp/device/idProduct /tmp/massStorageProduct
echo 03f0 > /sys/devices/virtual/android_usb/android0/f_mass_storage/device/idVendor
echo 5607 > /sys/devices/virtual/android_usb/android0/f_mass_storage/device/idProduct
echo 1 > /sys/class/android_usb/android0/enable

Content of script mtp.sh:

#!/bin/sh

if [ -f /tmp/massStorageFunctions ]; then
    echo 0 > /sys/class/android_usb/android0/enable
    cp /tmp/massStorageFunctions /sys/devices/virtual/android_usb/android0/functions
    cp /tmp/massStorageVendor  /sys/devices/virtual/android_usb/android0/f_mass_storage/device/idVendor
    cp /tmp/massStorageProduct /sys/devices/virtual/android_usb/android0/f_mass_storage/device/idProduct
    sudo -u phablet udisksctl mount -b /dev/mmcblk1p1
    echo 1 > /sys/class/android_usb/android0/enable
fi;

Note, that the vendor and product ids are stolen from another usb-mass storage device.

I have saved these scripts in the directory ~phablet/bin. Furthermore, I have defined the following aliases for starting the scripts from the com.ubuntu.terminal command line:

alias u='sudo sh ~phablet/bin/massStorage.sh'
alias m='sudo sh ~phablet/bin/mtp.sh'

You can set these aliases in the .bashrc-file within the home directory of phablet.

Note, that you must input your pin to detach/attach the sd-card with these scripts.


Remark: One big problem with the alternative solution mtp proposed by the others is that it is not available from within cygwin. One can use mtp within windows but the mtp devices are not provided as a drive letter which is needed for cygwin. I have essentially the same use case as Tor Thommesen and found this solution to expose my secondary sd-card of the phone as mass storage device.