Connecting Samsung ICS to Ubuntu using MTP

(These notes are mostly for my own benefit).

Android is moving away from USB Mass Storage. You will no longer be able to plug in a USB cable and have your Android show up as a USB disk. There are some good technical reasons for this, but it is a pain if you want to copy some files to your phone. The new system - MTP - isn't automagically detected in Ubuntu. This is something which is likely to be fixed in later versions of Ubuntu - but for now you'll have to hack around it.

The crazy cats at omgUbuntu have a tutorial which I have adapted for the Samasung Galaxy S (running ICS from teamhacksung).

First, install the MTP tools.

sudo apt-get install mtp-tools mtpfs

Connect the phone to the computer using USB.

To check that MTP is installed and working, run the command

mtp-detect

You should see a spool of text as MTP detects the phone.

To create the rules which allow Ubuntu to detect the phone, create a new rule file like so:

sudo nano /etc/udev/rules.d/51-android.rules

Add in this line of text

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666"

If you're using a different device, run this command to get the correct idVendor and idProduct:

mtp-detect | grep idVendor
mtp-detect | grep idProduct

We'll need to restart udev so it can pick up the new rule.

sudo service udev restart

Then create a directory in your filesystem which you can use to access your phone.

sudo mkdir /media/GalaxyS
sudo chmod a+rwx /media/GalaxyS

Now we need to add ourselves to fuse.

sudo adduser YOURUSERNAME fuse
sudo nano /etc/fuse.conf

The last line probably reads

#user_allow_other

Remove the "#" so you're left with:

user_allow_other

Save the file.

We're going to create two commands "android-connect" and "android-disconnect". When run, these will allow you to connect to your phone, then safely disconnect.

echo "alias android-connect="mtpfs -o allow_other /media/GalaxyS"" >> ~/.bashrc
echo "alias android-disconnect="fusermount -u /media/GalaxyS"" >> ~/.bashrc
source ~/.bashrc

Restart the computer. Make sure the phone is connected via USB. Open a terminal and run

android-connect

Open your file manager and go to "/media/GalaxyS"
ICS MTP

Once you're done, disconnect the device by running

android-disconnect

14 Comments

A picture of Simon Simon

Thanks :-)
Just make it working on mu ubuntu....
Its annoying so many things we need to do before things start working correctly on linux... But its worth it ;)

Reply
A picture of dex dex

can you simply set the USB debugging mode?
This should set by default the connection to the PC in USB storagew mode, so you'll see the storage and not the MTP.

Another point is that MTP on linux is really slow.
Can we find a way to speed it up?

Reply
A picture of Gustavo Gustavo

Didn't work for me. I get the following message on run the 'android-connect': fuse: bad mount point `/media/GalaxyTab7Plus': Transport endpoint is not connected.
My device is Galaxy Tab 7 Plus, it use de same idVendor and idProduct as GalaxyS
Can anyone help me?

Reply
A picture of Hervé Hervé

I'm on a new version of Precise (12.04). After the nude installation, if I connect my Galaxy S3, I see it in Nautilus, it is automounted. If I try to open it, I see the first level of directories, but they are empty.
I followed this post, I typed "android-connect" and when I open Nautilus on /media, it waits and doesn't display anything (even not my other mount points).

Any hint ? How can we connect the Galaxy S3 to Ubuntu ?

Reply
A picture of Marvin Marvin

I tried the instructions mentioned here, but no luck :(
getting error:
“alias android-disconnect=”fusermount -u /media/GalaxyS”
“alias: command not found
“alias android-disconnect=”fusermount -u /media/GalaxyS”
“alias: command not found
“alias android-disconnect=”fusermount -u /media/GalaxyS”
“alias: command not found
“alias: command not found
“alias: command not found
“alias android-disconnect=”fusermount -u /media/GalaxyS”
“alias: command not found
“alias android-disconnect=”fusermount -u /media/GalaxyS”
“alias: command not found
“alias android-disconnect=”fusermount -u /media/GalaxyS”
“alias: command not found
“alias android-disconnect=”fusermount -u /media/GalaxyS”

now im unable to access any of my folders on my pc. im running ubuntu 12.
Please help!!!

Reply
A picture of paddyrooney paddyrooney

Thanks for this great help in getting access to my JB device, just thought this little script might help some people who wish to just click an icon to do this work without having to run a command... so this does not require you to create the ~/.bashrc entry
In a terminal

echo " #!/bin/bash
if mountpoint -q /media/GalaxyS ; then
fusermount -u /media/GalaxyS
else
mtpfs -o allow_other /media/GalaxyS
fi" > MTPattach.sh

Now create a launcher to this file which will mount/umount it

Reply
A picture of andy andy

I found I could use the samba mount I had setup to share files with a windows PC. I used file expert to connect to samba and then I could browse and copy/paste as needed.

Reply
A picture of Dan Saint-Andre Dan Saint-Andre

When I connect my Galaxy Note i717, it identifies as a Galaxy Tab 10.1 before I do any file edits. 'dmesg' does not reveal any other Samsung device detected. How do I get it to ID as a Note i717 (vs. N7000) instead? How do I config once I get a correct ID? Doesn't MTP handle creation and removal of the /media/xxxxx folder and mounting?

Reply
A picture of Art Elsea, Jr. Art Elsea, Jr.

Brand new Galaxy S III from Sprint running Android 4.1.1

Running Ubuntu 10.04.4 LTS on workstation

kernel 2.6.32-45-generic #101-Ubuntu SMP Mon Dec 3 15:39:38 UTC 2012 x86_64 GNU/Linux

Followed instructions exactly, but android-connect gives error message:

fuse: bad mount point `/media/GalaxyS': Transport endpoint is not connected

Any suggestions or is it a lost cause with 10.04.4 LTS?

Thanks

Reply

Leave a Reply