ZNHOO Whatever you are, be a good one!

MTP

MTP (Media Transfer Protocol) is a protocol to allow the transfer of files to external devices. It is provided by several programs, most of them depending on FUSE.

From both the iOS and Android posts, we resort to Thunar (with gvfs support). In this post, I will show manually how to manage MTP device (Windows phone, Android, and even Creative Zen player) files. Irrespective of methods adopted, almost all packages implementing MTP depend on libmtp and/or FUSE.

Android doesn't support mounting your phone as a USB mass storage device anymore (from Android 3.0 onwards). Instead, put device into MTP mode and then access to device through MTP package. Take Android for instance, upon connected to computer, the device would prompts you to choose the mode, usually writing "charging only", "transmit files" and "tansmit photos". Just select the 2nd option.

There are a bunch of MTP packages like mtpfs, go-mtpfs, jmtpfs etc. Specially, gphotofs is a FUSE-based file system for interfacing with digital cameras using the gphoto2 application.

mtpfs is almost orphaned. Here I will take jmtpfs for example. Please make sure:

  1. Relevant Udev rule is created for your device like that in Android post.
  2. Also check if user belongs to plugdev group.
root@tux / # emerge -avt jmtpfs
user@tux ~ $ mkdir ~/mnt
user@tux ~ $ jmtpfs -h; jmtpfs -l
user@tux ~ $ jmtpfs ~/mnt
user@tux ~ $ ls ~/mnt
user@tux ~ $ fusermount -u ~/mnt

That's all!

To simplify the process by regular mount, we create jmtpfs entry in /etc/fstab.

Firstly, make symbolic similar to mount.fuse:

root@tux ~ # ln -sv /usr/bin/jmtpfs /usr/bin/mount.jmtpfs

Then, add to /etc/fstab:

# /etc/fstab

jmtpfs /home/user/run/motog fuse noauto,noatime,nodev,user,uid=1000,gid=1000 0 0

Of the options, user means any other accounts besides root can mount the entry.

Finally:

user@tux ~ $ mount ~/run/motog
user@tux ~ $ ls ~/run/motog

Interestingly, you will find even root cannot access to /home/user/run/motog, which is FUSE security restriction! What is more, umount is not allowed. Check man page of mount.fuse. To allow other accounts and/or root to read/write device files and umount, we should turn on 'user_allow_other' option in FUSE configuration /etc/fuse.conf:

# /etc/fuse.conf

# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
user_allow_other

Append 'allow_other' or 'allow_root' to mounting options. Before this takes effect, remember to reboot system:

# /etc/fstab

jmtpfs /home/user/run/motog fuse noauto,noatime,nodev,user,allow_root,uid=1000,gid=1000 0 0

Up to now, I have demonstrated mounting MTP devices and file permissions thereof. To detach the device, most libmtp based packages resort to fusermount:

user@tux ~ $ fusermount -u ~/run/motog

If 'allow_other' or 'allow_root' is enabled, then use umount:

user@tux ~ $ umount ~/run/motog