Difference between revisions of "Media Transfer Protocol"

From ArchWiki
Jump to: navigation, search
(Unable to enumerate USB device: adjust template)
m (mtpfs)
Line 64: Line 64:
 
=== mtpfs ===
 
=== mtpfs ===
  
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}
+
{{警告 | 以下的操作可能不能正常的工作,你必须求助于 [[Digital_Cameras#libgphoto2|gphoto2]] 或者是其他基于 gvfs 的文件管理器(如[[PCManFM]])。}}
  
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:
+
首先,编辑 {{ic|/etc/fuse.conf}} 然后注释掉以下内容:
 
  user_allow_other
 
  user_allow_other
  
Mount your device on {{ic|~/mnt}}:
+
将设备挂载到 {{ic|~/mnt}}
 
  $ mtpfs -o allow_other ~/mnt
 
  $ mtpfs -o allow_other ~/mnt
  
Unmount device mounted on {{ic|~/mnt}}:
+
{{ic|~/mnt}} 卸载设备:
 
  $ fusermount -u ~/mnt
 
  $ fusermount -u ~/mnt
  

Revision as of 04:46, 30 April 2015

zh-CN:MTP

MTP, or the Media Transfer Protocol, is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).

Installation

Functionality

Linux MTP support is provided by libmtp which can be installed with libmtp from the official repositories. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds.

These packages to choose from all implement a Wikipedia:Filesystem in Userspace:

All of them aim at better functionality and performance over libmtp. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours.

Tip: It is recommended to reboot your computer after installing MTP related packages.

Integration with file managers

To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:

After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example mtp://[usb:002,013]/.

Usage

It might be required to create a mount-point directory first. The directory ~/mnt is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.

libmtp

Detect your device:

# mtp-detect

If an error is returned, see troubleshooting libmtp.

Note: Your regular user must be in the uucp group.

Connect to your device:

# mtp-connect

If connection is successful, there are several switch options to use in conjunction with mtp-connect to access data on the device. You might want to use some stand alone commands:

 mtp-albumart        mtp-emptyfolders    mtp-getplaylist     mtp-reset           mtp-trexist
 mtp-albums          mtp-files           mtp-hotplug         mtp-sendfile
 mtp-connect         mtp-folders         mtp-newfolder       mtp-sendtr
 mtp-delfile         mtp-format          mtp-newplaylist     mtp-thumb
 mtp-detect          mtp-getfile         mtp-playlists       mtp-tracks
Warning: Some commands may be harmful to your MTP device!

mtpfs

警告: 以下的操作可能不能正常的工作,你必须求助于 gphoto2 或者是其他基于 gvfs 的文件管理器(如PCManFM)。

首先,编辑 /etc/fuse.conf 然后注释掉以下内容:

user_allow_other

将设备挂载到 ~/mnt

$ mtpfs -o allow_other ~/mnt

~/mnt 卸载设备:

$ fusermount -u ~/mnt

jmtpfs

Mount device on ~/mnt:

$ jmtpfs ~/mnt

Unmount device mounted on ~/mnt:

$ fusermount -u ~/mnt

go-mtpfs

Note: Mounting with go-mtpfs fails if external SD Card is present. If you have also external SD Card please remove it and then try mounting again.

Install android-udev, which will allow you to edit /etc/udev/rules.d/51-android.rules and apply to your idVendor and idProduct, which you can see after running mtp-detect. To the end of the line, add your user OWNER="<user>". First, create the fuse group if it doesn't exist:

# groupadd fuse

Add yourself to the fuse group:

# gpasswd -a <user> fuse

Reboot might be required.

Mount device on ~/mnt:

$ go-mtpfs ~/mnt

Unmount device mounted on ~/mnt:

$ fusermount -u ~/mnt

simple-mtpfs

List MTP devices:

$ simple-mtpfs --list-devices

Mount your device on ~/mnt:

$ simple-mtpfs ~/mnt

Unmount device mounted on ~/mnt:

$ fusermount -u ~/mnt

Media players

You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit /etc/udev/rules.d/51-android.rules (the MTP device used in the following example is a Galaxy Nexus). Run:

$ lsusb

Search for your device. It should be something like that:

Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]

And entry to /etc/udev/rules.d/51-android.rules will be this:

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"

Also reload udev rules:

# udevadm control --reload

Troubleshooting

libmtp

Unknown device

If you see a message like:

Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team

You should check whether your device is listed in the supported devices list. If it is not, you should report it to the developers team. If it is, your libmtp might be slightly outdated. To allow it to be properly used by libmtp, you can add your device to:

/etc/udev/rules.d/69-libmtp.rules

Unable to enumerate USB device

Merge-arrows-2.pngThis article or section is a candidate for merging with [[]].Merge-arrows-2.png

Notes: Unrelated to MTP, perhaps suited for USB storage devices (Discuss in Talk:Media Transfer Protocol#)

If you see a message like this in system log (journalctl)

 usb usb4-port2: unable to enumerate USB device

You can try following temporary workaround

 # modprobe -vr uhci_hcd
 # modprobe -va ohci_hcd
 # modprobe -va uhci_hcd

If it works you should create /etc/modprobe.d/usb_hci_order.conf with following content

 # create a dependency on ohci for uhci, which fixes problems
 # with external usb devices not showing up
 #
 softdep uhci_hcd pre: ohci_hcd

gvfs-mtp

Merge-arrows-2.pngThis article or section is a candidate for merging with udev.Merge-arrows-2.png

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:Media Transfer Protocol#)

If you have installed the gvfs-mtp package, and your device doesn't show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.

Plug your device and get the vendor-id and product-id,respectively:

$ lsusb
Bus 001 Device 007: ID 0421:0661 Nokia Mobile Phones Lumia 920
(...)

The two numbers after ID are vendorId : productID

Then make a udev rule, e.g.

# nano /etc/udev/rules.d/51-android.rules

and type this rule:

ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp",  MODE="660", ENV{ID_MTP_DEVICE}="1"

Reload the udev rules.

# udevadm control --reload

And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [1]

kio-mtp

If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file /usr/share/apps/solid/actions/solid_mtp.desktop.

Change the line

Exec=kioclient exec mtp:udi=%i/

To

Exec=dolphin "mtp:/"