Around a year ago, I wrote this handy-dandy article on OMG! Ubuntu!. While that method worked perfectly for the first few months, changes in libmtp, mtpfs and Ubuntu’s fuse libraries have made that method unreliable and buggy.
And very slow too, that is, if you managed to get the thing working.
So here’s another way to connect an Android device to Ubuntu, which, to much surprise, actually works (woohoo!). Instead of mtpfs, you’ll be using the amazing go-mtpfs library. Just run these commands to install go-mtpfs:
sudo apt-get install golang fuse git-core libmtp-dev libfuse-dev sudo adduser $USER fuse mkdir /tmp/go GOPATH=/tmp/go go get github.com/hanwen/go-mtpfs sudo mv /tmp/go/bin/go-mtpfs /usr/bin/ mkdir ~/MyAndroid
Now, go-mtpfs is installed. To mount your Android device, run these commands:
go-mtpfs ~/MyAndroid &
Voila! Your device’s contents can now be found at the MyAndroid folder in your home directory. If you belong to the “everything must be unmounted safely” tribe (like I do), then here’s your birthday present unmounting command:
fusermount -u ~/MyAndroid
That’s it! Not very simple, but it’s not like you’ll be able to find a more reliable method, can you?
I couldn’t wait to try this out, until I received this.
john@thinkndev:~$ export GOPATH=/tmp/go
john@thinkndev:~$ go get github.com/hanwen/go-mtpfs
# github.com/hanwen/go-mtpfs
mtp.go:16:20: fatal error: libmtp.h: No such file or directory
compilation terminated.
john@thinkndev:~$
The compilation wasn’t successful. How can I fix this?
You need to add libmtp-dev:
sudo apt-get install libmtp-dev
Hi John,
You were missing libmtp-dev and libfuse-dev. I’ve fixed the post to reflect it.
Actually, there is a very reliable way, and it is called SSH.
Except, not everyone is aware of the risks of SSH. Also, there are security risks of keeping a port open. And some phones might block opening ports.
Why not jus use Airdroid ?
Love Airdroid!!!
Works great and very fast with Nexus 7 and Galaxy Nexus. Thank you very much.
Hi Skomli,
Please help, let me know?
I just installed the packages & on Ubuntu that was running on virtual box on my windows. I installed the USBTest app on my Google nexus S, And just connect both with usb. But nothing happen on both..
I am not sure what can i do.. Is there any think i do for communicating with both?
Please tell me the process How you did please….?
Thank you..
Bilal, I get this error:
$ 2012/12/09 23:15:15 compiled against libmtp 1.1.3
Device 0 (VID=18d1 and PID=4ee1) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
2012/12/09 23:15:15 device unknown: unknown (18d1:4ee1) @ bus 1, dev 6
:
Seems like libmtp 1.1.3 does not support your device. You’ll have to use a newer version of libmtp.
Download it from here: http://sourceforge.net/projects/libmtp/files/libmtp/1.1.5/libmtp-1.1.5.tar.gz/download
Extract it, then inside it’s directory, run these commands:
sudo apt-get build-dep libmtp
./configure –prefix=/usr && make && sudo make install
sudo rm -f /usr/bin/go-mtpfs
mkdir /tmp/go
GOPATH=/tmp/go go get github.com/hanwen/go-mtpfs
sudo mv /tmp/go/bin/go-mtpfs /usr/bin/
mkdir ~/MyAndroid
Then try running the go-mtpfs ~/MyAndroid again. Should work now.
OK, now I get another error:
configure: error: invalid variable name: `–prefix’
Those are actually two hyphens, like this: – - (without the space in between them). WordPress autocorrected it to a single long dash.
after this command iget this error what to do?
./configure –prefix=/usr && make && sudo make install
configure: error: invalid variable name: `–prefix’
Actually if you switch your device to connect using PTP mode, gvfs-photo2 manages to mount it, and you can transfer stuff to and from your phone without any issues. You can even transfer music in using Banshee, but existing music gets detected as “Other”
PTP has been very spotty for me on Quantal. Gvfs often fails to mount my phone when it’s connected using PTP, and only 1 out of every three times I try connecting my phone using PTP, it works.
Go-mtpfs, on the other hand, has been really reliable.
not the case with all situations. ptp mode was so slow i quit after waiting 5 minutes. tried again a few times and ust gave up. go-mtp is the best solution for anyone connecting via usb to their android. air droid is ok but not much good if you arent online.
May want to update git-core to just git…git-core is obsolete.
FWIW I KDE 4.9.4+ users can just use dolphin…the mtp io slave works fine in the latest version of KDE.
Any idea why I’m getting:
/bin/fusermount: mountpoint is not empty
/bin/fusermount: if you are sure this is safe, use the ‘nonempty’ mount option
2012/12/17 13:31:41 mount failed: fusermount exited with code 256
nonempty: command not found
The MyAndroid folder in your home directory is not empty. Mount points should always be empty. Create a new directory, like AndroidPhone or something in your home directory then try running the go-mtpfs command again:
go-mtpfs AndroidPhone &
Hey, anyone managed to get this working for a S3 with Jellybean? Using libmtp 1.1.5, my phone screen unlocked and getting this error:
mguillech@mguillech-laptop:~$ 2012/12/19 18:54:41 compiled against libmtp 1.1.5
Device 0 (VID=04e8 and PID=6860) is a Samsung GT P7310/P7510/N7000/I9070/I9100/I9300 Galaxy Tab 7.7/10.1/S2/S3/Nexus/Note/Y.
2012/12/19 18:54:41 device Samsung: GT P7310/P7510/N7000/I9070/I9100/I9300 Galaxy Tab 7.7/10.1/S2/S3/Nexus/Note/Y (04e8:6860) @ bus 2, dev 8
:
mguillech@mguillech-laptop:~$ PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
inep: usb_get_endpoint_status(): No data available
outep: usb_get_endpoint_status(): No data available
usb_clear_halt() on IN endpoint: Protocol error
usb_clear_halt() on OUT endpoint: Protocol error
usb_clear_halt() on INTERRUPT endpoint: Protocol error
ignoring usb_claim_interface = -99LIBMTP PANIC: failed to open session on second attempt
2012/12/19 18:55:41 rdev.open: open: open returned nil
[1]+ Exit 1 go-mtpfs ~/MyAndroid
Other people on the comments of this post are reporting similar messages with new Samsung devices.
It’s most likely a bug with libmtp, since the error messages aren’t coming from go-mtpfs, but instead from libmtp. Would be great if you filed a bug on the libmtp project page. You might want to give a slightly older version of libmtp (1.1.4) a try to see if the newer one broke something, but I doubt if it will help. Your best bet is to file the bug and wait for the devs to fix it (in usual cases, it shouldn’t take long, the libmtp devs are quite prompt).
I got a similar error with my SG3. I think they key was to unmount the device wrt gnome/gphoto2. I tried again after that and it worked.
Nothing happen
mohammad@mohammad-OptiPlex-390:~$ go-mtpfs ~/MyAndroid &
[1] 10055
mohammad@mohammad-OptiPlex-390:~$ 2012/12/20 12:00:27 compiled against libmtp 1.1.4
Device 0 (VID=04e8 and PID=6860) is a Samsung GT P7310/P7510/N7000/I9070/I9100/I9300 Galaxy Tab 7.7/10.1/S2/S3/Nexus/Note/Y.
2012/12/20 12:00:27 device Samsung: GT P7310/P7510/N7000/I9070/I9100/I9300 Galaxy Tab 7.7/10.1/S2/S3/Nexus/Note/Y (04e8:6860) @ bus 1, dev 5
:
Thanks – this works on my Samsung Galaxy Tab 2 7.0 tablet allowing access to both the internal memory and the SD card. Previously, only the Calibre e-book reader was able to access it, and it still can.
I do get an “Error” on the first line saying “
Error: Unable to open ~/.mtpz-data for reading.” but it doesn’t seem to disable the operation at all. I tried creating this file, but then I got an error “Error: Unable to read MTPZ public exponent from ~/.mtpz-data“, which also didn’t seem to hurt anything. Any idea what this “error” is?Sorry, I probably should have added I’m using Ubuntu 12.03, in case that matters.
No luck either on Galaxy Nexus.
[2] 20711
dsg@dsgthink:~$ 2012/12/30 09:28:48 compiled against libmtp 1.1.4
Device 0 (VID=04e8 and PID=685c) is a Samsung Galaxy Nexus/Galaxy S i9000/i9250, Android 4.0 updates.
2012/12/30 09:28:48 device Samsung: Galaxy Nexus/Galaxy S i9000/i9250, Android 4.0 updates (04e8:685c) @ bus 1, dev 14
:
Android device detected, assigning default bug flags
2012/12/30 09:28:48 storage ID 65537: Internal storage
2012/12/30 09:28:48 backing data /tmp/go-mtpfs462418802
/bin/fusermount: failed to open /etc/fuse.conf: Permission denied
/bin/fusermount: failed to access mountpoint /home/dsg/MyAndroid: Permission denied
2012/12/30 09:28:48 mount failed: fusermount exited with code 256
Thank you very much! Works fine for my Sony Xperia tipo. Wondering why not include this package in Ubuntu by default? It would be helpful for any Android user and avoid the hassle of searching the method of accessing the Android phones. Also, being a Linux variant why Android devices left behind from Linux/Ubuntu community for auto mount methods?
I’m getting this error message with my Galaxy Nexus. Maybe I’m missing something?
Error: Unable to open ~/.mtpz-data for reading.
2013/01/07 20:44:15 compiled against libmtp 1.1.5
2013/01/07 20:44:15 no device found. Try replugging it.
As the message states, have you tried replugging your Galaxy Nexus?
I wouldn’t have posted if I hadn’t tried plugging and re-plugging…that’s kind of obvious
Open the notification shade when the cable is connected, and change the connection type to PTP and then back to MTP. Then try running the command again. I’ve seen, this simple trick often makes the device visible to the system again.
Hi!
I compiled with libmtm 1.1.5, but my device (LG Optimus L5) is still not recognized.
I’ve got this errors:
2013/01/09 18:08:58 compiled against libmtp 1.1.5
Device 0 (VID=1004 and PID=631c) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
2013/01/09 18:08:58 found device unknown: unknown (1004:631c) @ bus 2, dev 3
:
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
Android device detected, assigning default bug flags
2013/01/09 18:09:20 No storages found. Try unlocking the device.
What do they mean?
finally a method that actually works, thanks!
but why all those “ancient” problems with parallel transfer and “hiccups”, broken copies, etc…?
I can’t get this to work. The instructions work fine but when I try to access my nexus 7 from ubuntu 12.04, e.g. sudo ls ~/MyAndroid, I get:
Internal storage
I have tried changing to PTP and I can then acces my photos but when I switch back to MTP, nothing.
Do I Do I have to root my nexus?
I am getting this error..
013/02/06 17:31:50 detect failed: ambiguous devices: SAMSUNG SAMSUNG_Android 4df1a7b65c6f9ff9, SAMSUNG SAMSUNG_Android 4df1a7b65c6f9ff9
What to do?
Ty
Works perfectly, thanks a lot
media folder in ~/LGe400L3
commands:
in: go-mtpfs LGe400L3/
out: fusermount -u /home/amedeo/LGe400L3
LG Optimus L3 e400, Kubuntu 12.10 3.5.0-25-generic #39-Ubuntu x86_64
Hello,
I am newby in Android, using a Samsung 3G Tablet 10.1 (GT-N8000). I followed all steps, but now I am getting:
$ go-mtpfs ~/MyAndroid
2013/03/14 12:25:29 selectStorages failed: EOF
also
$ lsusb
shows
Bus 002 Device 004: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II]
It is there! All I am want is an easy way to transfer photos and videos taken with the tablet to my desktop PC (Ubuntu 12.04)
Any ideas?
Bump…
After restart the computer, Samsung is mounted and I can see all folders, but no files (all folders are shown as empty). I tried the command again:
$ go-mtpfs ~/MyAndroid &
[1] 2906
but after a while the error message changed:
silveira@trabalho:~$ 2013/03/14 12:38:02 OpenSession failed: LIBUSB_ERROR_TIMEOUT; attempting reset
Hello! This is kind of off topic but I need some advice from an established blog.
Is it difficult to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking
about setting up my own but I’m not sure where to start. Do you have any points or suggestions? Thank you
i get this output on writing “go-mtpfs ~/MyAndroid &”
user@laptop:~$ 2013/04/01 23:42:25 OpenSession failed: LIBUSB_ERROR_IO; attempting reset
2013/04/01 23:42:26 Configure failed: OpenSession after reset: LIBUSB_ERROR_IO
and then it just stops there and nothing happens..
Pingback: Conectar un Android 4.0 o superior vía MTP en Linux | Geekotic
phekbcmph, tblmlumzcb
I get an error trying to mount, I tried the mount command with and without the “&”, thus:
matt@matt-netbook:~/Desktop$ sudo go-mtpfs ~/MyAndroid
[sudo] password for matt:
/bin/fusermount: failed to access mountpoint /home/matt/MyAndroid: Permission denied
2013/04/10 20:17:58 mount failed: fusermount exited with code 256
matt@matt-netbook:~/Desktop$ sudo go-mtpfs ~/MyAndroid &
[1] 6837
matt@matt-netbook:~/Desktop$ /bin/fusermount: failed to access mountpoint /home/matt/MyAndroid: Permission denied
2013/04/10 20:18:31 mount failed: fusermount exited with code 256
Any ideas?
Some really excellent articles on this website , thankyou for contribution.
I receive the following error:
libusb_open() failed!: Permission denied
LIBMTP PANIC: Unable to initialize device
2013/04/28 20:42:06 rdev.open failed: open: open returned nil
Any idea what to do?
Sorry Buddy, everything was going okay, untill I reached here…
Can you please help me out?
Thanks for your note. Have a nice time and take care.
Hug and love.
Ashoke
——————————————-
ashoke@ashoke-desktop:~$ sudo adduser $USER fuse
The user `ashoke’ is already a member of `fuse’.
ashoke@ashoke-desktop:~$ mkdir /tmp/go
mkdir: cannot create directory `/tmp/go’: File exists
ashoke@ashoke-desktop:~$ GOPATH=/tmp/go go get github.com/hanwen/go-mtpfs
ashoke@ashoke-desktop:~$ sudo mv /tmp/go/bin/go-mtpfs /usr/bin/
ashoke@ashoke-desktop:~$ mkdir ~/MyAndroid
ashoke@ashoke-desktop:~$ go-mtpfs ~/MyAndroid &
[1] 11057
ashoke@ashoke-desktop:~$ 2013/05/03 23:22:21 OpenSession failed: LIBUSB_ERROR_IO; attempting reset
2013/05/03 23:22:28 Configure failed: OpenSession after reset: LIBUSB_ERROR_TIMEOUT
I had the same problem:
While the Android device is on I pulled the USB cable from the computer and plugged it back in. It was then recognized and showed up as Android.
What can I say, it worked.
Ric
When someone writes an paragraph he/she maintains the plan of a user in
his/her mind that how a user can understand it. Thus that’s why this piece of writing is outstdanding. Thanks!
Hello there, just became alert to your blog through Google, and found that it is truly informative.
I’m going to watch out for brussels. I’ll be grateful if you continue this in
future. Many people will be benefited from your writing. Cheers!