Getting your MTP devices working on Linux

Fusing MTP

Remember I mentioned earlier that libmtp is just a C library for programmers to make their applications talk to your MTP device? One such application is MTPfs, which is a FUSE file system that will mount an MTP device and allow you to write files onto the device in a much more familiar fashion.

If you look in your distro's repository, you will not find MTPfs. The only way to obtain it is to grab the source tarball off the website [3] and install it:

$ tar xvf mtpfs-0.9.tar.gz -C /tmp
$ cd /tmp/mtpfs-0.9
$ ./configure
$ make
$ su -c "make install"
$ sudo make install

Once it is installed, create a mount point:

$ sudo mkdir /media/jogpod

Now you can plug in the device, wait for it to settle down, and the mount it with mtpfs:

$ mtpfs /media/jogpod

In the mounted directory, you'll see the folders for Images, Music, Videos, etc. as they exist on your device. With the cp command, you can copy files to the appropriate directory, and with the rm command, you can delete files. Alternatively, you could use your desktop's file manager, but Nautilus crashed on me several times when I tried to copy files.

In the mounted device, you'll also notice a Playlists directory that contains all the playlists. To make your own playlist, use your favorite text editor to create a file that lists the name of the tracks you want in it, one per line. Then save this file with a .m3u extension and copy it over to the Playlists directory. I would suggest creating the file outside the mount point and then copying it into the mounted player.

When you're done, unmount the device with fusermount -u /media/jogpod.

MTP Meets Zune

Thanks to a .NET-speaking buddy, I was able to get my hands on a first-generation Microsoft Zune player. You would assume that because Microsoft promotes MTP so actively, you'd have no trouble working with Zune on Linux, but you would be wrong.

To begin with, the Zune uses the MTPZ protocol, which is a ZUNE-specific extension to MTP. Before any copy operation, MPTZ sends an encrypted challenge to the computer, which must respond by decrypting the challenge message with a key and sending a proper reply. To add this functionality in libmtp, the developers need authentication and a signed certificate from Microsoft to authenticate, which they don't have.

So any attempts to copy files to the Zune player will throw ACCESS DENIED errors. In fact, all you can do is list the files on the Zune and delete them. And you thought that just because you paid for the device, you could use it anyway you wanted to!

Converting Videos for MTP Devices

Many media devices also play videos. But unlike music files, you can't just copy any video files onto your MTP player. To get them to play properly, the videos have to be transcoded into the proper format and resolution with the use of tools such as FFmpeg, Mencoder, or Handbrake.

To transcode videos for your device, refer to the vendor documentation and jot down the limitations you're working with in terms of video resolution, aspect ratio, video and audio bit rate, sampling rate, and number of channels, as well as the video container and codec supported by your device.

Some device vendors try to throw you off balance with their own custom format, such as Samsung and its Samsung Audio Video Interleaving (SVI) format, which is nothing but their own AVI container format. You can use the SVIcoder [7] tool to transcode videos for playback on Samsung devices.

MTP Support in Music Players

In addition to the command-line tools discussed in this article, a couple of popular music players on the Linux desktop support MTP devices: Amarok for KDE users and RhythmBox for Gnome. Both RhythmBox and Amarok include code from libmtp, so just make sure you grab the most recent version from your distro's repositories.

To get your MTP devices to work on RhythmBox, you will have to activate the MTP plugin. First go to Edit | Plugins, which will open the Configure Plugins dialog box (Figure 1). Next, scroll down the list of plugins to find and enable the Portable Player – MTP plugin. Now connect the device, and RhythmBox will pick it up.

Figure 1: RhythmBox bundles MTP support as a plugin.

Similarly, with Amarok, you need to activate support for MTP devices. To do so, head over to Settings | Configure Amarok | Media Device (Figure 2). You'll have to add your device manually with the Add Device option, which involves selecting the MTP plugin from a pull-down list and entering a name for the device. After adding the device, return to the main interface and click on the Devices tab. There, select MTP Media Device from the pull-down list and click on the Connect button.

Figure 2: If you're lucky, Amarok will autodetect your MTP device.

Once your device is listed, you can drag and drop files into the player and play music from it.

A few other applications support MTP devices. For example, if you have one of the Creative Nomad players, you can transfer music onto it with Gnomad2 [4], which also is written by one of the libmtp developers. The Banshee and Audacious music players will talk with MTP devices as well.

If you are a developer and want to write your own app for communicating with MTP devices, you can use either the original libmtp library written in C, the Ruby wrapper [5], or the Python wrapper [6].


Although an MTP device might not behave like a simple mass storage device at first glance, thanks to the developers of libmtp, you will hardly notice any differences when you use MTP devices on Linux.


  1. libmtp Project:
  2. Download libmtp:
  3. MTPfs FUSE filesystem for reading MTP devices:
  4. Gnomad2 for several players from Creative and Dell:
  5. Ruby wrapper for libmtp:
  6. Python wrapper for libmtp:
  7. SVIcoder:

The Author

Mayank Sharma has written for various Linux publications. He has published two books through Packt on administering Elgg and Openfire. Occasionally he teaches FLOSS technologies. You can reach him via

Read full article as PDF:

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:


njobs Europe
Njobs Netherlands Njobs Deutschland Njobs United Kingdom Njobs Italia Njobs France Njobs Espana Njobs Poland
Njobs Austria Njobs Denmark Njobs Belgium Njobs Czech Republic Njobs Mexico Njobs India Njobs Colombia