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 flags for sys-fs/mtpfs A FUSE filesystem providing access to MTP devices

debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces global
mad Enable handling of MP3's metadata local

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 allow_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 USE flag enabled.

FILE /etc/portage/package.use
gnome-base/gvfs mtp

KDE

KDE SC 4

kio-mtp is a slave for KDE's KIO framework. It is still unstable, but it is in the main repository.

First, install:

root #emerge --ask kde-misc/kio-mtp

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

KDE 5

kio-extras contains MTP support, but it requires the mtp use flag.

Enable the global mtp use flag:

FILE /etc/portage/make.conf
USE="$USE mtp"

ALTERNATIVELY, enable it in kio-extras:

FILE /etc/portage/package.use
kde-apps/kio-extras mtp

Then, install:

root #emerge --ask kde-misc/kio-mtp

After this, quitting KDE and restarting is probably sufficient to get it working. If that does not work, please try restarting you system.

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.
  • Lumia devices must be unlocked to be able to connect (enter your PIN).

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