Since Android switch from mass storage to MTP, it’s being hard to connect an Android phone to Linux and use it to browse files. I had that problem every single day, having to resort to another choices.
I’ve tried this on Gentoo Linux and Ubuntu 12.04, but I guess it should work on any distribution.
Since using mass storage, two partitions cannot be mounted simultaneously, Android developers switch to MTP. Here’s a better explanation
Some parts of this tutorial have been borrowed from here: http://www.omgubuntu.co.uk/2011/12/how-to-connect-your-android-ice-cream-sandwich-phone-to-ubuntu-for-file-access
Most credits should go to Bilal Akhtar (from http://www.omgubuntu.com).
What I’ve did was taken a step further. Since udev can execute scripts automatically, why not use udev to manage most of the operations?
Note: unless specified, all commands are to be run as the root user (or if you use sudo, just prepend sudo to the commands)
Install packages
For this to work, we’ll rely on fuse and libmtp
Ubuntu:
apt-get install mtp-tools mtpfs
Gentoo:
emerge -av sys-fs/fuse sys-fs/mtpfs media-libs/libmtp
Go to /media (or /mnt) and create a folder with a relevant name for the device
cd /media
mkdir AsusFT201
We’re doing this because udev only knows about the removed device when you actually remove it and that’s is not good to remove the device without first umount it. Here’re going with Bilal Akhtar solution (references in the bottom of the document) and have an alias to umount the device
Now, on the computer, run the following command:
tail -f /var/log/messages (or tail -f /var/logo/syslog on Ubuntu)
Now connect your device to the computer. In your device, make sure to select “Media device (MTP)”
The kernel messages after connecting the device:
Oct 8 16:43:27 nightraider kernel: [ 5263.446971] usb 1-3: default language 0×0409
Oct 8 16:43:27 nightraider kernel: [ 5263.447477] usb 1-3: udev 11, busnum 1, minor = 10
Oct 8 16:43:27 nightraider kernel: [ 5263.447479] usb 1-3: New USB device found, idVendor=04e8, idProduct=6860
Oct 8 16:43:27 nightraider kernel: [ 5263.447481] usb 1-3: New USB device strings: Mfr=2, Product=3, SerialNumber=4
Oct 8 16:43:27 nightraider kernel: [ 5263.447483] usb 1-3: Product: SAMSUNG_Android
Oct 8 16:43:27 nightraider kernel: [ 5263.447484] usb 1-3: Manufacturer: SAMSUNG
Oct 8 16:43:27 nightraider kernel: [ 5263.447486] usb 1-3: SerialNumber: 111X1111XY11111Z
Oct 8 16:43:27 nightraider kernel: [ 5263.447552] usb 1-3: usb_probe_device
Oct 8 16:43:27 nightraider kernel: [ 5263.447555] usb 1-3: configuration #1 chosen from 2 choices
SerialNumber is the line we’re looking for.
With this value, let’s create the udev rules.
create the following file:
(I use vi, you can use emacs or gedit. Still, you don’t know what you’re missing by not trying vi)
vi /etc/udev/rules.d/81-android.rules
Read here why the file is called 81-android.rules
and add the following lines (replace 111X1111XY11111Z with the serial with your device):
SUBSYSTEM==”usb”, ATTRS{serial}==”111X1111XY11111Z”, MODE=”0666″, GROUP=”plugdev”, SYMLINK+=”AndroidPhone”, RUN+=”/usr/bin/mtpfs -o allow_other /media/ AsusFT201″
Notes:
The full path of the commands is necessary. Read the udev manual for more information
I went with serial because it is unique and I’ve seen the idDevice change in the same computer. – can someone confirm if this is possible ?
Now save and quit the editor.
Reload the udev rules:
udevadm control –reload-rules
Now, edit /etc/fuse.conf and remove the comment from the last line (just delete the ‘#’)
From:
#user_allow_other
to:
user_allow_other
Add yourself to the fuse group (if not already)
To find out, type:
id (as your user)
uid=1000(username) gid=1000(username) groups=1000(username),4(adm),24(cdrom),27(sudo),29(audio),30(dip),44(video),46(plugdev),60(games),105(fuse),109(scanner),111(lpadmin),115(netdev),124(sambashare),1012(sharing),1013(bumblebee)
If you don’t have the group in your list, just run the following command:
gpasswd -a <your_username> fuse
Adding user <your_username> to group fuse
On Gentoo you need to add your user to the group disk
The command is the same, just replace fuse with disk
You need to logout and login again for it to take effect (if not in the group)
After that, just plug your device and wait a bit. I’m saying wait a bit because for me, my phone (with ICS) and my tablet (with JB) take a while to mount. Don’t know why. This happens in both distributions.
Umounting
To unmount the device, just edit your .bashrc file (in your home) and add the following lines:
vi ~/.bashrc
Give it the name you want – replace android-disconnect
alias android-disconnect=”fusermount -u /media/AsusFT201″
Save and quit
Now, execute the command:
source ~/.bashrc
Now you can remove the device issuing the command android-disconnect
References:


Nice guide but I can get it work… I’m using Ubuntu 12.10 and when I plug it in after following the steps I get this error: “Sorry, could not display all the contents of “SAMSUNG_Android”: Timeout was reached”
This is all nonsense, when I plug my android phone into Mandriva Linux 2011 a pop up says I’ve connected a new device and gives me the option of opening it with the KDE file manager, one click and viola, I can access my files. The need to do what’s in the above guide with distros like Ubuntu or Gentoo give Linux a bad name.
You are correct, but the truth is, is necessary. I can’t mount my Android with MTP… You can do this because someone already did that and it’s included in your rules. The problem is not Linux, are the vendors.