Embracing simple-mtpfs as the true MTP tool

2021-01-30

(last time edited: 2021-04-23)

tags: mtp, storage, smartphones

MTP

The Media Transfer Protocol (MTP) is an extension to the Picture Transfer Protocol (PTP) communications protocol that allows media files to be transferred automatically to and from portable devices. Whereas PTP was designed for downloading photographs from digital cameras, Media Transfer Protocol allows the transfer of music files on digital audio players and media files on portable media players, as well as personal information on personal digital assistants. MTP is a key part of WMDRM10-PD, a digital rights management (DRM) service for the Windows Media platform. In 2011, it became the standard method to transfer files from/to Android.

Ok good, now that we know what MTP stands for.

Anyways, I have used a lot android-file-transfer-linux for years. It's a nice little user friendly graphical tool that simplifies transferring files to your smartphone. Never got into troubles until now.

timeout reaping usb urb

Anyways, I did fix that problem by enabling Developer Mode in my smartphone and enabling USB Debugging.

This program also needs to be executed as root to access the smartphone. We do not want that!

Why not go a little more simpler and secure and flip the finger to android-file-transfer? Who needs graphical interfaces anyways?

simple-mtpfs

simple-mtpfs (Simple Media Transfer Protocol FileSystem) is a file system for Linux (and other operating systems with a FUSE implementation, such as Mac OS X or FreeBSD) capable of operating on files on MTP devices attached via USB to local machine.

simple-mtpfs is a really really simple command-line program that would let you temporarily mount your smartphone as a normal user in a directory so you can transfer your files without hassle.

Preparations

First of all make sure to disable all developer mode options in your smartphone, including USB Debugging. We do not need that.

Install simple-mtpfs.

As root create udev rules. We are real men, we don't use systemd.

# touch /usr/lib/udev/rules.d/51-android.rules

And add the rules found here.

In Void Linux is not necessary to add these rules manually or create the adbusers group manually.

You can just do.

# xbps-install android-udev-rules

And XBPS will add the rules file and create the group automatically.

Now add your user to the adbusers group.

# groupadd adbusers (just in case)

# usermod -aG adbusers your_user

Re-login to your shell session and reload udev rules as root.

# udevadm control --reload-rules

Basic usage

Create a temporal directory to mount your smartphone.

$ mkdir /path/to/androiddir

List connected devices.

$ simple-mtpfs -l

Mount your device, we do not need root. A normal user can handle the FUSE filesystem mounting thanks to the udev rules. Replace $NUMBER with the device number found in the previous command.

$ simple-mtpfs --device $NUMBER /path/to/androiddir

Unmount your device.

$ fusermount -u /path/to/androiddir

Debugging

There are multiple tools to debug correctly.

That's all folks.