Configure MTP in Linux

  Last modified on Wednesday 08 October 2014

Many MP3 players and recent Android phones and tablets no longer appear as removable USB storage devices under Linux. Instead they use MTP (Media Transfer Protocol) and to enable these devices to be detected, mountable, and usable by Linux requires a bit of configuration.

This is how I setup my laptop to work with Nexus 4 and Nexus 7 devices. These steps should work with any MTP-enabled device with the only difference being Android-specific configuration and the relevant vendor or device IDs for each device.

To configure MTP under Debian:

0. Developer Options

On the Nexus I enable developer options by navigating to Settings->About {tablet,phone}, click to open and make +7 taps on Build number. Nexus displays You are now a developer.

Return to settings and Developer Options is now visible. Click to open and activate USB debugging.

1. MTP

Install MTP packages and assign USER to the plugdev group:

$ sudo apt-get install mtp-tools mtpfs
$ sudo adduser USER plugdev

Logout and re-login to activate new group permissions.

2. Udev

Connect the MTP-enabled device to Linux and make note of the idVendor and idProduct codes. Sample output from my Nexus 7:

$ lsusb | grep Google
Bus 001 Device 009: ID 18d1:4e41 Google Inc. ASUS Nexus 7 (MTP modus)

Google's idVendor=18d1 and the Nexus 7 is idProduct=4e41. Disconnect the device. Create a new udev rule for Nexus devices in /etc/udev/rules.d/99-android.rules:

# Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666"

Note

For a generic entry to handle all Google devices use idVendor. Otherwise add idVendor and idProduct codes to make a device-specific udev rule.

3. MTPFS

MTPFS is a FUSE filesystem that enables reading and writing data to the MTP-enabled Nexus. Create a mount point for the tablet and restart the udev daemon:

$ sudo mkdir /media/nexus
$ sudo service udev restart

Connect the (not in sleep mode) tablet and access onboard storage by running:

$ sudo mtpfs /media/nexus -o allow_other

Unmount the device when finished:

$ sudo umount mtpfs

Alternate options such as Airdroid exist for device storage management over wireless connections that are OS-independent. MTP is useful to setup if you plan to install development tools and root your device.

Happy hacking!

More • androiddebianlinux