Android MTP

To mount an Android 4 phone (I have a Galaxy S2 with Android 4.1.2), you must use the MTP protocol. You can no longer mount it using the USB mass storage protocol, because this won't work on devices that have only a single partition (because you can't unmount the phone's system partition in order to mount it on the PC).

You can mount an Android phone via USB (go to Settings -> ‘Wireless and networks’ ‘More settings’ -> ‘USB utilities’ -> ‘Connect storage to PC’, then mount as you would any other USB storage device) but that won’t work if you have an encrypted SD card - you’ll be able to see all files but their contents will be encrypted hence unusable.

To mount the phone and see the SD card’s contents decrypted, you’ll need to use MTP.

I initially followed the Gentoo MTPfs instructions and various other guides such as [How to] Connect your Android Ice Cream Sandwich Phone to Ubuntu for File Access that worked with mtpfs, but I kept getting the following error:

Transport endpoint is not connected

Also listing the mounted directory came back showing question marks:

bpc steph # ls -l /mnt
ls: cannot access /mnt/s2: Transport endpoint is not connected
total 0
?????????? ? ?    ?      ?            ? s2

I ditched mtpfs. Simple MTPFS worked.

Simple MTPFS

emerge -av simple-mtpfs

It has media-libs/libmtp as a dependency. I got a problem with version 1.1.6-r1 (see media-libs/libmtp fails to compile (glibc-2.20?) so I masked it and used 1.1.8 instead.

Make a mount point:

mkdir /mnt/s2

Mount:

simple-mtpfs /mnt/s2

Unmount:

fusermount -u /mnt/s2

You could something like the following to /etc/fstab to use the normal mount command:

simple-mtpfs                    /mnt/s2         fuse            noauto,noatime,sync,ro,users    0 0

Mount:

mount /mnt/s2

Unmount:

umount /mnt/s2

E.g.:

bpc steph # mount /mnt/s2
Unable to open ~/.mtpz-data for reading, MTPZ disabled.
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
bpc steph # ls -l /mnt/s2
total 0
drwxrwxr-x 2 root root 0 Jan  1  1970 Card
drwxrwxr-x 2 root root 0 Jan  1  1970 Phone
bpc steph # umount /mnt/s2
bpc steph # ls -l /mnt/s2
total 0

Gotchas

Unlock the phone

I found that the phone has to be unlocked before it will mount.

Only works as root

I couldn’t get this working for normal users, only root. Normal users get the following:

me@pc ~ $ mount /mnt/s2
Unable to open ~/.mtpz-data for reading, MTPZ disabled.
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
me@pc ~ $ ls -l /mnt/s2
total 0
me@pc ~ $ umount /mnt/s2
umount: /mnt/s2: not mounted

TODO: Get this working for normal users!

Phone contents empty

The last time I tried this, the Phone directory only contained empty directories - no files!

The contents of the Card directory was fine.

In the end I had to use MTP to get the contents of the (encrypted) SD card and USB to get the contents of the phone! All a bit of a mess really.

References

Last modified: 03/01/2016 Tags: ,

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top