Thursday, July 19, 2012

Connect Nexus 7 to Linux via MTP using USB


Android 4.1 use the MTP (Media Transfer Protocol) and Linux doesn't natively support MTP. Something it doesn't work well with Linux/Ubuntu. When I connect my Nexus 7 to a Server running Linux using USB, none USB device appears and I have to mount it via MTP for accessing the file system.

How to Connect Nexus 7 to Linux
Open the terminal window and type the commands to setup.
* First install the necessary tools:
  sudo apt-get install mtp-tools mtpfs
* Set up a UDEV rule
  gksu gedit /etc/udev/rules.d/51-android.rules
* Type this text in it. Make sure all are in a single line:
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="your-username-in-the-linux"
* Set up a mount point
  sudo service udev restart
  sudo mkdir /media/Nexus7
  sudo chmod a+rwx /media/Nexus7
* Plug your Nexus 7  in and select MTP on the tablet, then enter:
  sudo mtpfs -o allow_other /media/Nexus7
* Now You can browse your Android phone contents or add/remove/modify files using Nautilus. When you need To unmount, try this:
  sudo umount mtpfs

34 comments:

  1. It works with my Nexus 7!
    Thank you!

    ReplyDelete
  2. I just get Playlists and Internal folders. Clicking Internal just opens the device again.

    ReplyDelete
  3. @Matt.
    Got same issue as yours initially,
    Fixed by subs ATTR{idVendor} and ATTR{idProduct} values with your own Google device ID from lsusb.

    run lsusb, you will see this something like,
    Bus 001 Device 010: ID 18d1:4e41 Google Inc.
    18d1 is the idVendor
    4e41 is the idProduct

    ReplyDelete
  4. Thanks, that helped a bunch!

    ReplyDelete
  5. Works with my Nexus 7, Thanks !

    ReplyDelete
  6. thanks a lot...helped me a lot :)

    ReplyDelete
  7. Thanks a million!

    ReplyDelete
  8. Thanks! you are the man! I think I love u!... can you explain why is it necessary?

    Thanks again.

    ReplyDelete
  9. Thank you. This worked well for me with Daniel's comment making all the difference. I only see the folders:
    Alarms DCIM Movies Notifications Playlists Ringtones
    Android Download Music Pictures Podcasts
    I wanted to copy my clockworkmod backup to ubuntu but I am still struggling to see that :(

    ReplyDelete
  10. this didn't work for me... i followed the directions but it is saying file not found when i double click the Nexus7 folder

    ReplyDelete
  11. Great and simple, thank you!
    Worked on Linux Mint + Nexus 7

    ReplyDelete
  12. Thanks a lot!
    Worked in my ubuntu 12.04 LTS

    ReplyDelete
  13. Works on Ubuntu 11.04 with Daniel's comment, i.e. the idVendor and idProduct needed changing.

    ReplyDelete
  14. Thanks, it worked first time!
    Ray Carbuhn

    ReplyDelete
  15. 10x - Works with Daniels note. But it's slooooooooow. Better install ES File Explorer on the tablet and transfer files from/to shared PC foler(s)

    ReplyDelete
  16. 10x - Works with Daniels note about lsusb. But so slooooooow. Better install ES File Explorer from market and then transfer from/to shared PC folder(s)

    ReplyDelete
  17. For those who don't want to deal with MTP, there's always mounting over wifi with sshfs and the SSHDroid app.

    I've been using that on my gnexus and nexus 7.

    ReplyDelete
  18. Couldn't quite get this method to work. downloaded a program from the Ubuntu software center called gMTP. Was able to get my music on to my Nexus using that. Not as seemless as dragging and dropping files there but it did what I needed it to so.

    ReplyDelete
  19. This method did not work for me. I ended up downloading gMTP from the Ubuntu software center. I was able to connect and copy my music from my Ubuntu Pc to the Nexus 7 pretty quickly. Not as easy as drag and drop or copy and paste but did what I needed

    ReplyDelete
  20. if you don't get this worked on nautilus, try other file managers like PCManFM.

    ReplyDelete
  21. works well thank you guys!!!!

    ReplyDelete
  22. Followed this and everything worked fine. Was able to move movies and stuff to my Nexus 7. Thanks Alot :D

    ReplyDelete
  23. Thank you SO MUCH.

    It worked flawlessly.

    Nexus7 running jellybean 4.2.2 (unmodified). And ubuntu 12.04.

    ReplyDelete