Friday, 17 August 2012

Mounting a Nexus 7 on Ubuntu 12.04

..or any other Android 4+ device really. Here's a quick step by step guide to get your Nexus 7 (in my case) mounted on Ubuntu.


1. Install some modules
sudo apt-get install mtp-tools mtpfs

2. Create the file 99-android.rules in /etc/udev/rules.d/

sudo vi /etc/udev/rules.d/99-android.rules


Pasted in the the following..
# Nexus 7

SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"


2. Make it executable
sudo chmod +x /etc/udev/rules.d/99-android.rules

3 Restart udev
sudo service udev restart

4. Create a mount point

sudo mkdir /media/nexus7

chmod 755 /media/nexus7


5. Plug in device and ensure MTP is enabled

On the Nexus 7 bring down the menu, select usb connection and make sure the 'Media device (MTP)' is sticked and then..


sudo mtpfs -o allow_other /media/nexus7



Remember to umount the device

sudo umount /media/nexus7

df -h
.. to report storage levels

16 comments:

  1. Hello!

    Thanks for posting this - been trying for a while to get my Nexus 7 to mount for USB data transfer in Ubuntu (albeit I'm running 11.04).

    I got up to #2 ok, but then where do I paste in the "# Nexus 7..." information? I tried pasting into terminal but nothing seems to happens...

    Should I create a file using gEdit in that location and copy/paste the info there, then continue using the terminal commands?

    Thanks a lot for your help :-)

    ReplyDelete
    Replies
    1. Thanks for your help on this - it all worked well, even with a warning about permissions.

      Thanks again :-)

      Delete
  2. Hi Dale, yes paste in the lines beginning '# Nexus' and 'SUBSYSTEM==' into the file '/etc/udev/rules.d/99-android.rules'. Give that a go

    ReplyDelete
  3. my problem was the device appears mounted but does not allow me to copy onto to it error "Could not change permissions for /media/nexus7/Internal storage/Pictures/cccccccccc.jpg"

    I did as you suggested and still get the permissions error

    any ideas

    ReplyDelete
  4. Sounds like you need to adjust your mounting permissions. Look into mtpfs -h

    ReplyDelete
  5. Here's what I get...

    nathan@nathan-1213:~$ df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda1 451G 118G 311G 28% /
    udev 3.9G 8.0K 3.9G 1% /dev
    tmpfs 1.6G 1.2M 1.6G 1% /run
    none 5.0M 8.0K 5.0M 1% /run/lock
    none 3.9G 382M 3.6G 10% /run/shm
    df: `/media/nexus7': Transport endpoint is not connected
    nathan@nathan-1213:~$ cd /media/nexus7
    bash: cd: /media/nexus7: Transport endpoint is not connected

    ReplyDelete
  6. Even I am facing similar issue as Nathan

    ReplyDelete
    Replies
    1. Once you've plugged in your nexus 7 have you, in the drop down menu select the usb connection and make sure 'Media device (MTP)' has a ticked check box

      Delete
  7. Thanks for help :-) I just have one question, is it possible, that Ubuntu mounts Nexus 7 everytime it detects, that Nexus is connected to USB?

    ReplyDelete
  8. Thanks for this howto. I'm using Ubuntu 12.04 and the SYSFS key is not recognized by udev. However, the following rule worked:

    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e41", MODE="0666" OWNER=""

    HTH,
    -mandeep

    ReplyDelete
  9. No need to make 99-android.rules executable, it's merely a configuration file.

    ReplyDelete
  10. Can we change the permissions so that it does not use the sudo? it will make much easier unmounting through nautilus

    ReplyDelete
  11. Anyone have learned how to sync using banshee ?

    ReplyDelete
  12. Thanks, this was helpful.

    ReplyDelete
  13. Works fine the first time. Thanks. RH

    ReplyDelete