Join me on Facebook!
— Written by Triangles on October 01, 2016 • ID 44 —
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.
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:
Then invoke jmtpfs, so that it can mount to that directory the first MTP device it finds:
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.
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)