MTP

From Gentoo Wiki
Jump to: navigation, search
Resources

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.


MTPfs

Installation

Kernel

Prepare for MTP implementations by activating CONFIG_FUSE_FS in the kernel:

KERNEL Activate FUSE for MTP implementations
File systems  ---> 
   <*> FUSE (Filesystem in Userspace) support

USE flags

USE flag (what is that?) Default Recommended Description
debug No Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml
mad No Enable handling of MP3's metadata

sys-fs/mtpfs depends on media-libs/libmtp. It turned out[1] that at least version 1.1.8[2] is needed to make it work.[3].

Emerge

Install sys-fs/mtpfs:

root #emerge --ask sys-fs/mtpfs

Configuration

Appropriate user need to be in the plugdev group:

root #gpasswd -a <USER_NAME> plugdev

Modify /etc/fuse.conf:

FILE /etc/fuse.conf
user_allow_other

Usage

user $mkdir ~/AndroidDevice
user $mtpfs ~/AndroidDevice
Unable to open ~/.mtpz-data for reading, MTPZ disabled.
Device 0 (VID=0bb4 and PID=0c93) is a HTC EVO 4G LTE/One V (ID1).
Android device detected, assigning default bug flags
Note
Be patient, as this can take several minutes. Upon successful mount, mtpfs will background itself.

Unmount:

user $fusermount -u ~/AndroidDevice

Go-mtpfs

Note
Newer Galaxy Devices (S3, S4, Note2, etc.) use their own MTP-stack and don't work reliably, although this should be fixed in newer versions. See Bug#29

Installation

We need to unmask 2 packages in /etc/portage/package.keywords:

FILE /etc/portage/package.keywords
dev-libs/go-fuse **
sys-fs/go-mtpfs **

Emerge

Install sys-fs/go-mtpfs:

root #emerge --ask sys-fs/go-mtpfs

Configuration

Appropriate users need to be in the plugdev group:

root #gpasswd -a <USER_NAME> plugdev

Usage

Mount:

user $mkdir ~/AndroidDevice
user $go-mtpfs ~/AndroidDevice &

Note: If you don't run go-mtpfs in the background (with & at the end), you will need another console to browse the device and to unmount it.

Unmount:

user $fusermount -u ~/AndroidDevice

When you unmount the device, go-mtpfs will quit.

gphotofs

gphotofs is a FUSE file system for interfacing with digital cameras using gphoto2. Most modern mobile phones are cameras at the same time, and gphotofs can be a good alternative to mtpfs or go-mtpfs.

Installation

Emerge

Install media-gfx/gphotofs:

root #emerge --ask media-gfx/gphotofs

Usage

Mount:

user $mkdir ~/AndroidDevice
user $gphotofs ~/AndroidDevice -o alllow_other
  • unmount:
user $fusermount -u ~/AndroidDevice

simple-mtpfs

Another FUSE file system implementation for use with MTP devices is simple-mtpfs.

Installation

Emerge

Install sys-fs/simple-mtpfs:

root #emerge --ask sys-fs/simple-mtpfs

Usage

Mount:

user $mkdir ~/AndroidDevice
user $simple-mtpfs ~/AndroidDevice

Unmount:

user $fusermount -u ~/AndroidDevice

Gnome

Install gnome-base/gvfs with the mtp useflag enabled.

USE flag (what is that?) Default Recommended Description
mtp No Enable support for Media Transfer Protocol

KDE

kio-mtp is a slave for KDE's KIO framework.

As kio-mtp is still unstable, but is now part of main repository. Then:

root #echo kde-misc/kio-mtp >> /etc/portage/package.accept_keywords
root #emerge --ask kde-misc/kio-mtp

Finally quit KDE, and relaunch it. Now your MTP devices appear e.g. in Dolphin.

gMTP

gMTP is a simple MTP client for Solaris and Linux.

It is sufficient to just install and run media-sound/gmtp:

root #emerge --ask media-sound/gmtp
user $gmtp

Click on connect. A few second later, you will get the file hierarchy of your device. You can start to manipulate the files. It support features like Album Artwork and play lists.

Thunar

To have thunar automount MTP and other volumes, install xfce-extra/thunar-volman

Troubleshooting

  • If your device is not recognized by libmtp, try upgrading to latest (or even live) version - e.g. 1.1.8.
  • Some ROMs(e.g. PAC rom) require to unlock the screen of your device. If you don't - you'll see the device as empty.
  • Sometimes (e.g. on HTC One X) USB debugging automatically turns on when device is connected to PC. You need to turn debugging off, otherwise libmtp can't recognize device.
  • Make sure your Android device is not going to sleep and the screen is not getting locked. Set screen timeout to very long values, or enable in Development section flag "Do not turn off the screen".
  • Lumia devices might require media-libs/libmtp version 1.1.9 and sys-fs/simple-mtpfs to be mounted properly.

References

  1. http://forums.gentoo.org/viewtopic-p-7633366.html#7633366
  2. bug #527086
  3. libmtp will scan the usb bus and send messages to the log for all attached usb devices
    Dec 29 11:58:42 localhost kernel: usb 1-1.2: new full-speed USB device number 8 using ehci-pci
    Dec 29 11:58:42 localhost mtp-probe: checking bus 1, device 8: "/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.2"
    Dec 29 11:58:42 localhost mtp-probe: bus: 1, device: 8 was not an MTP device
    Dec 29 11:59:51 localhost kernel: usb 1-5.1: new low-speed USB device number 10 using ehci-pci
    Dec 29 11:59:51 localhost kernel: input: Logitech Trackball as /devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.1/1-5.1:1.0/0003:046D:C404.0007/input/input25
    Dec 29 11:59:51 localhost kernel: hid-generic 0003:046D:C404.0007: input: USB HID v1.10 Mouse [Logitech Trackball] on usb-0000:00:1d.7-5.1/input0
    Dec 29 11:59:51 localhost mtp-probe: checking bus 1, device 10: "/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.1"
    Dec 29 11:59:51 localhost mtp-probe: bus: 1, device: 10 was not an MTP device
    Dec 29 11:59:51 localhost kernel: input: Logitech Logitech Illuminated Keyboard as /devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.4/1-5.4:1.0/0003:046D:C318.0008/input/input26
    Dec 29 11:59:51 localhost kernel: hid-generic 0003:046D:C318.0008: input: USB HID v1.11 Keyboard [Logitech Logitech Illuminated Keyboard] on usb-0000:00:1d.7-5.4/input0
    Dec 29 11:59:51 localhost kernel: input: Logitech Logitech Illuminated Keyboard as /devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.4/1-5.4:1.1/0003:046D:C318.0009/input/input27
    Dec 29 11:59:51 localhost kernel: hid-generic 0003:046D:C318.0009: input: USB HID v1.11 Device [Logitech Logitech Illuminated Keyboard] on usb-0000:00:1d.7-5.4/input1
    Dec 29 11:59:51 localhost mtp-probe: checking bus 1, device 11: "/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.4"
    Dec 29 11:59:51 localhost mtp-probe: bus: 1, device: 11 was not an MTP device