Like it!

Join me on Facebook!

Like it!

Android to Debian/Linux file transfer via MTP

A painless tutorial on how to share files from and to your Android device.

MTP stands for Media Transfer Protocol, a communication protocol used for moving files across portable devices. I never had the luck to make it work under the countless graphical file managers for Linux, so I decided to go the command-line way. For this purpose you will need a couple of small tools.

  • jmtpfs, used for accessing MTP devices. It is based on FUSE, a type of filesystem implemented as a "simple" user program (Unix filesystems are traditionally implemented in the kernel);
  • fusermount, used for mounting and unmounting FUSE filesystems.

Preparing the filesystem

First of all connect via USB the device you want to grab files from. In my case — I'm working with a Nexus 5 phone — I also have to switch it to "file sharing mode", but your mileage may vary.

Choose a directory where you want to temporarily mount your device's filesystem. You can use /mnt, or create a temporary directory in your home, like that:

mkdir ~/android_mount

Then invoke jmtpfs, so that it can mount to that directory the first MTP device it finds:

jmptfs ~/android_mount

If everything goes well you should see some information on your device, plus a device detection message. In my case I had the following:

Device 0 (VID=18d1 and PID=4ee1) is a Google Inc (for LG Electronics/Samsung) Nexus 4/5/7/10 (MTP).
Android device detected, assigning default bug flags

That's a good sign.

Browsing and unmounting

Now that the device filesystem is properly mounted, cd to your temporary directory (that is ~/android_mount) and do your stuff. Once you're done, you have to unmount the filesystem. Using fusermount the operation is straightforward:

fusermount -u ~/android_mount


Wikipedia - Media Transfer Protocol (link)
Wikipedia - Filesystem in Userspace (link)
Unix StackExchange - What are the benefits and downsides to use FuseFS filesystems? (link)
Manpages - Fusermount (link)