How To: Fix Samsung Galaxy Nexus MTP File Transfer for Ubuntu GNU/Linux 11.10

So I've been so lucky as to have a spankin' new Samsung Galaxy Nexus phone with Android Linux "Ice Cream Sandwich" version from Verizon bestowed upon me! Yeah!

I have to tell you, I am thoroughly enjoying this phone! I'm loving it! I really like the big screen, the great on-screen keyboard, the snazzy new Ice Cream interface, and most of all the 4G Internet speed.

There was only one little surprise for me with this new phone: Having to use the Media Transfer Protocol "MTP" ( ms ft technology), and/or the Photo Transfer Protocol "PTP" to transfer files to/from the device instead of USB Block mode. Both of my previous phones, the Moto Droid and then the Droid Incredible, used USB block mode instead.

The way USB block mode works is that when you plug the device into the USB port with the cable it is simply detected as an external USB drive. This is nice because no additional applications or proprietary frameworks are needed to access the drive.

With the Samsung Galaxy Nexus however,  you have to install some additional software so you can mount the device using "MTP" Media Transfer Protocol. I think it would be nice if you had the choice of using whichever one you want.

Update 01/02/13 - Want to skip having to compile anything and simply access your device as a drive instead? Then simply install "Go-mtpfs" from +WebUpd8. See this link for the instructions.

MTP works with GNU/Linux, but it requires the installation of some extra applications to get connected to the device. One such application is called gMTP by Darran Kartaschew (aka Chewy509).


The gMTP program is a graphical utility that lets you add/delete/copy/make folders/etc. to your device via MTP. gMTP is available in the Ubuntu Software Center.

The only problem I had with gMTP, which depends upon libmtp from sourceforge.com, is that the latest libmtp hadn't been updated on my Ubuntu (11.10) yet. So, since I had the older libmtp, I was experiencing a bug where trying to copy files onto my Samsung Galaxy Nexus wasn't working properly. At least one other person was having this problem, according to this post on sourceforge.com.  To make a long story short, I posted my complaint on G+ and then magically.. +Paul Eubanks suggested that I should check into installing the newer libmtp to fix the problem. This hit the nail on the head! Thanks Paul!
 
Eventually, probably within a few weeks or months, libmtp will be updated for Ubuntu, and then you won't experience the bug I did.. But until then, here are the instructions for installing the newer libmtp, after compiling it from source.

Warning:The method outlined here is meant to be an experimental / quick fix for testing. I say this because standard conventions of installing replacement shared libraries are not used here. For some great information on the subject, please have a look at this great post by Jeremy Mac Wright.

Assuming you are still OK with making such experimental changes to your system, here are the instructions:

Step 1. Install the libusb-dev dependency package so you can build libmtp
sudo apt-get install libusb-dev
Step 2. Download the latest libmtp tar.gz from here:
http://sourceforge.net/projects/libmtp/files/libmtp/

Step 3. cd into the same directory where you downloaded the new libmtp*.tar.gz and extract the tar package:
tar xvf libmtp-1.1.1.tar.gz
Step 4. cd into the libmtp directory you just extracted , then compile and install using configure/make/make install:
cd libmtp-1.1.1/
./configure --prefix=/usr
make
sudo make install
Step 5 (maybe optional). Not sure if I needed this step or not, but if everything in the last step went well, you'll now have the 69-libmtp.rules file in the current directory, and you can copy it to /etc/udev/rules.d to ensure you can access the phone through the USB.
sudo cp 69-libmtp.rules /etc/udev/rules.d
Step 6. Install the handy gMTP Graphical MTP file access utility:
sudo apt-get install gmtp
Step 7. Try to run gMTP and see if it connects to your device. If not, then refresh things by unplugging your phone, rebooting the computer, then plugging in your phone again. Then, try to launch gMTP from the Unity/Gnome menu again, see below.




Step 8. You should see something like below when you click connect. Also you should be able to copy files to and from the device with ease.



If you want to check to ensure your computer has the newer libmtp, run this command:
ls -lah /usr/lib/libmtp*
You should see something like below.. notice the libmtp.so.9.0.1 and file date there
svanwagner@ubuntu-scythe:/usr/lib$ ls -lah libmtp.* -rw-r--r-- 1 root root 725K 2011-12-18 01:12 libmtp.a -rwxr-xr-x 1 root root 921 2011-12-18 01:12 libmtp.la lrwxrwxrwx 1 root root 15 2011-12-18 01:12 libmtp.so -> libmtp.so.9.0.1 lrwxrwxrwx 1 root root 15 2011-12-18 01:12 libmtp.so.9 -> libmtp.so.9.0.1 -rw-r--r-- 1 root root 256K 2011-08-09 06:10 libmtp.so.9.0.0 -rwxr-xr-x 1 root root 611K 2011-12-18 01:12 libmtp.so.9.0.1
Here's an extra tip: The gMTP program version 1.2.0 has the root of the filesystem "/" set for the "Download" control (by default). So if you launch the program normally, when you select a file and click "Download", you'll get an error because the program will have tried to save the file to "/", which unless you run your computer as root - is not writable by regular users. To fix this problem, you should open Edit > Preferences for gMTP, then place a checkmark by "Always show Download Path", as shown in the picture below. With this setting enabled, you'll be prompted for a location to store the file when clicking "Download", and you can pick something like Desktop or your Documents folder so you can get your files.



That's it! Now you can move files on and off your Samsung Galaxy Nexus device with ease!

Update: pointed out how the libmtp update does not help the problem with connecting  the Nexus to Banshee or even Rhythmbox.

To have Banshee see your Samsung Galaxy Nexus (Android):
  • Close out of banshee completely
  • Plug in your phone and open the root folder (select open folder on plug-in prompt)
  • Create an empty file, rename it to ".is_audio_player" (no quotes)
  • Open the Banshee Music player and it will see your device
To have Rhythmbox see your Samsung Galaxy Nexus (Android):
  • Simply enable Debugging Mode on the Phone, then attach it to the computer
Credit:
http://www.omgubuntu.co.uk/2011/01/banshee-doesnt-show-android-fix/
https://bugs.launchpad.net/ubuntu/+source/banshee/+bug/896376

Want to try a different way? See here: http://www.omgubuntu.co.uk/2011/12/how-to-easily-mount-the-galaxy-nexus-on-ubuntu-11-10-via-unity/

If you'd like to leave a comment, please do so below.


Cheers!
Shannon VanWagner
12-18-11
 




Comments

  1. thanks, this helped :)

    ReplyDelete
  2. Great write up. Thanks Shannon!

    ReplyDelete
  3. Shannon,

    I use Gentoo and had libmtp-1.1.1 installed and could access the device fine but could not write to my Galaxy Nexus, I had to re-emerge libmtp and my problems went away but if I never read your post I would still be bashing my head of why this isn't working. Thanks for the howto!

    ReplyDelete
  4. Thank You!!
    Excellent directions for the CC's of the world (Command challenged)
    Loven my Gnex

    ReplyDelete
  5. this is great for individual file copies, but fails for directory hierarchies containing .mp3 files, which are inexplicably placed in the root of the copy target rather than in their directories. other file types are properly placed in their target hierarchies. :/

    ReplyDelete
  6. >this is great for individual file copies, but fails for directory hierarchies containing .mp3 files, which are inexplicably placed in the root of the copy target rather than in their directories. other file types are properly placed in their target hierarchies.

    Me: hmm, I didn't seem to have this same problem. Although, I still would prefer to use the block mode over MTP, because then I could just use the OS to access the data rather than having to use an additional program. Anways, thanks to libmtp/gmtp/etc. at least I can get access.

    ReplyDelete
  7. Will this work with the samsung galaxy prevail?

    ReplyDelete
  8. >I think it would be nice if you had the choice of using whichever one you want.

    It's up to the phone makers if they want to use the old way of partitioning the internal flash storage or the new.

    Old: Where you need a "Move to SD" option to use all internal storage. When you plug-in the USB it unmount the SD-partition, there by allowing the PC to mount it. This also requires FAT32 to be included where Microsoft holds a long-filenames patent (most likely one of the 5 patents phone vendors pay to use).

    New: All apps and media are stored on a single partition, no more "Move to SD" that isn't really a SD in most phones. Use of the more modern file system EXT4 (compared to FAT32) on all partitions, this will most like improve speed (App load) as well as lower the chance for data to be lost during power failure. The downside of this is that you can't unmount to when the USB is pluged-in, since all apps are stored on it.

    Google solution was to use MTP to transfer files to/from the mounted partition. This will force a lot of Linux distributions to improve their MTP support.

    Another solution could be to implement a virtual USB storage device that mirrors everything on the internal storage. But this would have taken more time to implement and test.

    ReplyDelete
  9. +Bruno Thomsen - Good stuff. Thanks for the background on that.

    ReplyDelete
  10. Actually, if I connect the cable; set it to Camera (PTP) mode; unmount it from linux; and then enable Debugging mode (under Developer options), the drive pops up as a window (same as before), but this time I can write/drag files/drag folders/etc. It still doesn't show up under #df, but it seems to look like a normal folder at least...

    ReplyDelete
  11. Building libmptp 1.1.1 from source got me slightly further than before (gmtp and qlix now see that there is a device, although they don't see it as a Nexus, but then both segfault trying to connect). This is with Ubuntu Natty.

    Thankfully I can do file transfer with PTP/Camera Mode, and libmtp will only get better!

    ReplyDelete
  12. This looks very cool but one problem... there is only a 32-bit version of gMTP [does anyone really still use 32-bit computers? :-)]

    Any chance of an x86_64 version?

    Thanks!

    ReplyDelete
  13. >I think it would be nice if you had the choice of using whichever one you want.

    On my Galaxy Nexus I go to Settings>Storage>Menu>USB Computer Connection and choose Camera (PTP) and the device shows in Fedora without changing anything just as it shows in Windows.

    ReplyDelete
  14. Thanks for the great article.

    I have a Samsung Galaxy Tab 10.1 and had tried gmtp to no avail. I found your article and tried updating libmtp but still no luck.

    Running gmtp from the commandline gives the following:


    Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7510/Galaxy Tab 10.1.
    PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
    LIBMTP libusb: Attempt to reset device
    LIBMTP PANIC: failed to open session on second attempt
    Detect: Unable to open raw device?
    LIBMTP PANIC: Trying to dump the error stack of a NULL device!
    LIBMTP PANIC: Trying to clear the error stack of a NULL device!

    Any help you can give would be greatly appreciated.
    cheers

    ReplyDelete
  15. @lochutus - Apparently there's another way to try:
    Use ddms from sdk tools (follow instructions at http://developer.android.com/sdk/index.html to install sdk tools):
    Then go to Device > File Explorer > navigate to mnt,sdcard, then select the folder or files you want to transfer to your device > then click the "pull from device" icon, select a local destination to copy files (e.g., Desktop) and click OK.

    ReplyDelete
  16. Thanks heaps, shall give that a go.

    ReplyDelete
  17. I used PTP instead of MTP and didn't have to install or upgrade any software on my Linux-Mint 10.

    http://gurjeet-tech.blogspot.com/2012/02/how-to-use-mtp-on-googles-galaxy-nexus.html

    ReplyDelete
  18. as usual you are the man. I remember how helpful your post on how to root the original droid in Ubuntu was and once again you solved my problem. Thank you

    ReplyDelete
  19. Thank you , it works at once.

    ReplyDelete
  20. Didn't work. 64-bit 11.10 Ubuntu Samsung Galaxy Nexus

    "No device attached" Click "Connect" gets "Error" "Detect:No raw devices found."

    ReplyDelete
    Replies
    1. Use sudo gmtp, it will find the device

      Delete
  21. One more tutorial that suggests to trash your system.

    The right way is to install libmtp locally in your home directory (--prefix=$HOME/software), and to add $HOME/software/lib to LD_LIBRARY_PATH.

    ReplyDelete
  22. @Olivier Mengué - Hmm.. I'll have to ponder that and see if I can make a better write up. I wrote this up as a quick and dirty to get my program working, and it does, for me. I wonder how it would trash my system? Other than the libmtp not getting updated. I see there are examples of ways to use the LD_LIBRARY_PATH out there, e.g. http://www.wiredrevolution.com/system-administration/how-to-correctly-use-ld_library_path

    ReplyDelete
  23. Didn't work on Ubuntu/Kubuntu/Xubuntu (all amd64). Everytime it's the same issue. 'No device attached'. I clicked the 'Connect' button and after many seconds I saw the root folder of the Nexus, but with Error dialog over that - Failed to get storage parameters from the device - need to disconnect.

    ReplyDelete
    Replies
    1. Same here

      Delete
    2. Use sudo gmtp, it will find the device

      Delete
  24. You can just mount phone storage to the file system:
    # apt-get install mtp-tools libmtp9 mtpfs
    # mtpfs -o allow_other /mnt/somedir

    ReplyDelete
  25. Excellent write up! : )

    ReplyDelete
  26. Nice... thanks..

    ReplyDelete
  27. Thanks! this helped with my Nexus7

    ReplyDelete
  28. thanks a lot for the detailed write-up. tried it with my Galaxy S3 and Ubuntu 12.04. somehow some of it worked... )
    could not however make gMTP connect to my phone - keep getting 'Unable to open raw dvice' error. same with attempts to view the phone via Nautilus. BUT! when I changed connection mode on the pone to PTP I was finally able to see contents of internal SD. can also copy to/from phone albeit with some glitches like 'bad parameters' error when writing to phone. some folders/files do get copied, some don't. didn't figure out the logic here. the phone itself shows as 'store_00010001' (*0002 for external SD) in Nautilus window header, and as 'SAMSUNG_Android' (two times for both SDs) in nav bar. anyway, as a workaround it goes for the time being. looking for updates on that. thanks again for help.

    ReplyDelete
  29. I have a Samsung Galaxy Note (Android 4.0.4), PC (Ubuntu 12.04) and exactly the same problems/situation as Veal Kommissarov. I am beginning to hate MTP. Please help!

    ReplyDelete
  30. Rykel, I got gMTP working by starting it in terminal as superuser:
    ~$ sudo gmtp
    however, it's slow and buggy. I recommend using AirDroid instead. available thru Google Play.

    ReplyDelete
  31. @Debater:~$ sudo apt-get install gmtp
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package gmtp

    ReplyDelete
  32. Hola, any help here :

    alex@Alex:~$ sudo gmtp
    [sudo] password for alex:
    Device 0 (VID=04e8 and PID=6860) is UNKNOWN.
    Please report this VID/PID and the device model to the libmtp development team
    LIBMTP PANIC: Could not open session! (Return code 18432)
    Try to reset the device.
    Detectar: No se puede abrir el dispositivo de primas?
    LIBMTP PANIC: Trying to dump the error stack of a NULL device!
    LIBMTP PANIC: Trying to clear the error stack of a NULL device!


    am sure 100% my model

    if i run :

    alex@Alex:~$ mtp-detectlibmtp version: 1.1.2

    Listing raw device(s)
    Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
    Found 1 device(s):
    Samsung: Galaxy models (MTP) (04e8:6860) @ bus 1, dev 8
    Attempting to connect device(s)


    Got not idea what to do, any help would be welcome

    Thx a alot

    ReplyDelete
  33. Thanks. It worked like a charm

    ReplyDelete
  34. Very well written, and thoroughly explained. It worked flawlessly for me as well, thanks a bunch!

    ReplyDelete
  35. Thanks. Work on Sony Xperia GO.

    ReplyDelete
  36. Hi all, it all works nicely if the PPA in this article is used. My SGS2 connects as easily as it should to Ubuntu 12.10

    http://jaisejames.wordpress.com/tag/ubuntu-13-04/

    ReplyDelete
  37. thanks a lot!! work on Sony Xperia U.

    ReplyDelete
  38. thanks a lot it works flawlessly. Just one question, how do I watch / download movies on my Pc from Samsung Galaxy?I hae a movie in Video hub on the phone but not showing in gMTP.
    Thanks
    pmac

    ReplyDelete
  39. Worked for me with a Samsung Galaxy Reverb (Android 4.1.2) and Linux Mint. Nicely done.

    ReplyDelete
  40. Hi,
    Although it is an old article but it did provide me solution to connect my xperia p mobile to Ubuntu Linux machine. Thanks for your writeup, gonna translate this article into my local language once my blog is fixed (ofcourse with proper credit will be given to you).

    ReplyDelete
  41. Thank you for share this solution.
    Solved my problem.

    Contgratulations! :D

    ReplyDelete

Post a Comment

Thanks for commenting. Comments are moderated by the blog owner and will appear once approved. Need to email me directly? Go to http://shannonvanwagner.com/email-me.php

Popular posts from this blog

How To Connect Ubuntu Linux to Cisco VPN with openconnect (anyconnect-capable alternative)

(updated) How To: Ubuntu 16.04 GNU / Linux - Netgear Wireless AC Adapter AC600 ( AC6100 ) Dual Band

How To Set Default Grub / kernel / boot option on Ubuntu GNU/Linux 14.04