sorenpoulsen.com header

Nexus 9 file transfer via USB on Ubuntu

The Nexus 9 transfers files via USB using the Media Transfer Protocol (MTP). Ubuntu 16.04 supports this out of the box, whereas with older versions of Ubuntu, we have to set up a virtual filesystem to expose the MTP interface of the Nexus 9. This post covers both Ubuntu 16.04 and Ubuntu 12.04.

Ubuntu 16.04

File transfer from the Nexus 9 to a PC running Ubuntu 16.04 is straight forward. First connect the Nexus 9 with a USB cable. Then pull down the notification bar on the Nexus 9 and click the "USB for charging" entry.

A USB notification on Google Nexus9

Select "File transfer" (MTP mode) in the popup window.

Screendump of dialog to set Google Nexus 9 in file transfer mode (MTP)

On the PC running Ubuntu 16.04 open the Nautilus file manager and select Android in the sidebar. If you want to backup photo and video files you'll find them in the folder Internal storage > DCIM.

A screenshot of the Nexus 9 mounted in the filemanager on Ubuntu 16.04

When you are done copying files, click the Android ejection symbol in the sidebar to unmount the Nexus 9 safely.

Ubuntu 12.04

Configure the Nexus 9 Udev device node

Pluggable hardware device such as the Nexus 9 are managed on Linux by the udev service. When the Nexus 9 is plugged in the udev service will create a device node in the /dev file tree. To make sure our Linux user account has access to the device node, we must create a udev configuration file for the Nexus 9. First though, we need to determine the vendor and product ID of the device.

The lsusb command can list the information we need. If it's not installed on your system, then get it from Ubuntu's repository with apt-get:

$ sudo apt-get install usbutils

Connect the Nexus 9 and run lsusb:

$ lsusb
Bus 001 Device 002: ID 8087:8000 Intel Corp. 
Bus 002 Device 042: ID 18d1:4ee1 Google Inc.
Bus 002 Device 002: ID 06cb:0af8 Synaptics, Inc. 
Bus 002 Device 041: ID 0bda:5752 Realtek Semiconductor Corp. 
Bus 002 Device 004: ID 8087:07dc Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

From the output above we find a USB device from Google Inc. This can only be the Nexus 9. From the same line we determine that the vendor ID is 18d1 and product ID is 4ee1.

Create a Udev rule file that sets the permissions required to access a device node with this ID.

$ sudo nano /etc/udev/rules.d/85-nexus.rules

Paste the following content to the file and replace the vendor and product ID, if they were different for your device. Then save the file and exit with ctl+o, then ctl+x.

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee1", MODE="0664", GROUP="plugdev"

When ever a USB device is plugged in, udev reads through the rule files and if it finds a matching vendor and product ID, then it applies the permissions set in that rule file.

Re-connect the Nexus 9 and check the kernel log to see if the device is being detected.

$ dmesg
[116348.092698] usb 2-1: new high-speed USB device number 36 using xhci_hcd
[116348.110595] usb 2-1: New USB device found, idVendor=18d1, idProduct=4ee1
[116348.110603] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[116348.110608] usb 2-1: Product: Android
[116348.110612] usb 2-1: Manufacturer: Android gr8rFiV8US03C03C00
[116348.110616] usb 2-1: SerialNumber: HT4C3JT04163

Install mtpfs

mtpfs is FUSE based virtual file system. FUSE is already running, but we need to install mtpfs:

$ sudo apt-get install mtp-tools mtpfs

Open the FUSE config file.

$ sudo vi /etc/fuse.conf

And uncomment the line #user_allow_other and save the file. The file content should look something like this:

# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#
#mount_max = 1000

# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
user_allow_other

Add your user account to the fuse group:

$ sudo adduser <useraccount> fuse

Log in again.

Create a mount folder for the Nexus 9:

$ sudo mkdir /media/nexus9
$ sudo chmod a+rwx /media/nexus9

Create a script to mount and unmount the Nexus 9:

$ echo 'mtpfs -o allow_other /media/nexus9' > mountnexus9.sh
$ echo 'fusermount -u /media/nexus9' > unmountnexus9.sh
$ chmod u+x mountnexus9.sh unmountnexus9.sh

Mount the Nexus 9

Reconnect the Nexus 9.

On the Nexus 9 pull down the notification drawer and click "USB for charging".

A USB notification on Google Nexus9

In the "Use USB for" popup select "File transfers" (MTP mode).

Screendump of dialog to set Google Nexus 9 in file transfer mode (MTP)

Finally run the script we created earlier to mount the Nexus 9 storage:

$ ./mountnexus9.sh

The Nexus 9 storage is now available under /media/nexus9.

$ ll /media/nexus9
drwxrwxrwx 2 bob  bob     0 jan  1  1970 ./
drwxr-xr-x 4 root root 4096 mar 6 12:08 ../
drwxrwxrwx 2 bob bob 0 jan 1 1970 Alarms/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Android/
drwxrwxrwx 2 bob bob 0 jan 1 1970 backups/
drwxrwxrwx 2 bob bob 0 jan 1 1970 DCIM/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Download/
drwxrwxrwx 2 bob bob 0 jan 1 1970 .estrongs/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Movies/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Music/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Notifications/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Pictures/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Playlists/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Podcasts/
drwxrwxrwx 2 bob bob 0 jan 1 1970 Ringtones/

If you only see an empty folder named Playlists, then the Nexus 9 is not in MTP mode.

{{model.usr.name}}
{{cmt.user.name}}
{{cmt.user.name}}
{{childcmt.user.name}}
{{childcmt.user.name}}