打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
mtp



summary

Media Transfer Protocol (MTP) is used for transferring files (etc) between devices--notably, between newer Android or Microsoft smartphones and your Debian host.

Be aware that many smarphones will only enable MTP while the phone is not locked!*

Graphical User Interface

GNOME applications (like GNOME_Files and Archive_Manager) use GIO-based GVFS (the GNOME virtual file system) to mount MTP volumes and access files on MTP devices:

  • launch on attaching your device (e.g., with USB cable)
  • interact with an attached device (e.g., by double-clicking the device's icon in the device list).

Install package gvfs-backends Note: the gvfs-backends version in Debian Wheezy (7.0) may not recognize or mount all devices. Use versions >= 1.15.3.

KDE uses the MTP KIO Slave with a similar level of integration as GVfs.

A graphical tool that is not related to GNOME or KDE is gMTP, install package gmtp

libmtp

libmtp provides support for MTP devices. Its device support changes with each version of its code, thus you may need a particular version of libmtp (or greater) to support your particular device: e.g., the MotoG phone is not supported directly before libmtp version == 1.1.8 per its maintainers.

Commandline

Several tools provide a FUSE based file system for mounting MTP devices within the Unix filesystem hierarchy, making it accessible to any program that operates on files and directories. Examples include mtpfs, jMTPFS, go-mtpfs and simple-mtpfs, etc...

  1. mtp-tools

    • install package name=mtp-tools

    • TODO: document usage, but see below.

  2. jmtpfs

    • Uses FUSE to mount your device's MTP structure into a POSIX filesystem, and fusermount to unmount the device.

    • install package name=jmtpfs

    • create as your mount point: $ mkdir -p 

    • make sure you have write access to : $ sudo chown $USER:$USER 

    • to mount your device: $ jmtpfs 

      • On some MTP devices: your screen must be unlocked in order to mount. However, you might get a (spurious) input/output error even if the screen is unlocked.

    • to unmount your device: $ fusermount -u 

  3. mtpfs

    • mtpfs has been orphaned since Squeeze, anyway mtpfs is very similar to jmtpfs, except for the executable name, package name, and package status

    • install package name=mtpfs

    • to mount your device: $ mtpfs 

    • to unmount your device: $ fusermount -u 

testing and debugging device connection

Connect your target device (e.g., Android phone) to your Debian host (e.g., laptop) via USB cable, and unlock the target device. Relatively quickly, you should see the following:

  1. Your Debian host's desktop should open a file browser (e.g., a nautilus window) showing the browsable contents of a location. If the location is mounted in your filespace, you should not need to read further from this article. Alternatively, the location will be shown with a URI beginning with mtp://, which will not be mounted, but can be manipulated via the usual means provided by your file browser (including copying and deleting files). If you wish to actually mount that location (i.e., your target device), read on.

  2. The target device may also show some GUI, such as choosing the connection mode. If so, choose mode=MTP.

If neither of those occur, you should

  1. Check your connection, e.g., the USB cable. If fixing that does not make your target device browseable as described above, then ...
  2. Check which version of libmtp and associated packages you have installed on your Debian host: see following section=device statuses. Install them if not already done. You will minimally need to have the executable mtp-detect in your path.

  3. Run mtp-detect from your host with your target device attached.

If you see results like

$ sudo mtp-detect Unable to open ~/.mtpz-data for reading, MTPZ disabled.libmtp version: 1.1.8Listing raw device(s) No raw devices found.

... stop and seek help elsewhere. If you see results like

$ sudo mtp-detect Unable to open ~/.mtpz-data for reading, MTPZ disabled.libmtp version: 1.1.8Listing raw device(s)Device 0 (VID= and PID=) is UNKNOWN.Please report this VID/PID and the device model to the libmtp development team Found 1 device(s):

... your target device is not currently supported. As noted in the result, you should report it to the libmtp maintainers by making a feature request like this one.

If you see results like

$ mtp-detect Unable to open ~/.mtpz-data for reading, MTPZ disabled.libmtp version: 1.1.8Listing raw device(s)Device 0 <... remaining="" text="" omitted="" for="" this="" documentation,="" ending="" with/="">OK.

then you should be able to mount the target device onto your host's filespace as discussed in the following example.

Example: laptop, MotoG, USB, libmtp, jmtpfs

device statuses

I have a (working) 1st-generation Motorola MotoG running Android version=4.4.4 that I wish to mount on a Debian laptop. Latter has

$ cat /etc/debian_versionjessie/sid$ uname -rv3.11-2-amd64 #1 SMP Debian 3.11.8-1 (2013-11-13)$ gcc --version | head -n 1gcc (Debian 4.8.2-1) 4.8.2

Note that libmtp version >= 1.1.8 supports the MotoG per its maintainers. After fiddling with APT and my repositories, I have

$ aptitude versions --disable-columns mtp | grep -e '^Package\|^i' | grep -vie 'dovecot\|mtpaint\|smtp'Package gmtp:Package gmtp:i386:Package jmtpfs:i 0.5-2 100Package kio-mtp:Package kio-mtp-dbg:Package kio-mtp-dbg:i386:Package kio-mtp:i386:Package libmtp-common:i 1.1.8-1 100Package libmtp-dbg:Package libmtp-dbg:i386:Package libmtp-dev:Package libmtp-dev:i386:Package libmtp-doc:i 1.1.8-1 100Package libmtp-runtime:i 1.1.8-1+b1 100Package libmtp-runtime:i386:Package libmtp9:i 1.1.8-1+b1 100Package libmtp9:i386:i 1.01-3 testing 500Package mtp-tools:i 1.1.6-20-g1b9f164-1 testing 500Package mtp-tools:i386:Package python-pymtp:Package uucp-lmtp:

setup/check Debian host

# make mount point ...$ mkdir -p ~/Android_transfer/# ... and unmount it$ fusermount -u /home/me/Android_transfer$ ls -al ~/Android_transfer/total 8drwxr-xr-x 2 me me 4096 Apr 5 20:08 .drwxr-xr-x 50 me me 4096 Apr 5 21:09 ..

With no MTP devices connected to the laptop, I see (from the laptop)

$ date ; jmtpfs -lSun Apr 5 20:08:46 EDT 2015Unable to open ~/.mtpz-data for reading, MTPZ disabled.Available devices (busLocation, devNum, productId, vendorId, product, vendor):

successful jmtpfs mount

I then unlocked the MotoG's screen and connected it to the laptop with a USB cable.

Immediately upon connecting, a nautilus window opened on the laptop showing the browsable contents of location=mtp://[usb:001,040]/ with device name=XT1028. I can also see (from the laptop)

$ date ; jmtpfs -lSun Apr 5 20:09:06 EDT 2015Unable to open ~/.mtpz-data for reading, MTPZ disabled.Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).Available devices (busLocation, devNum, productId, vendorId, product, vendor):1, 41, 0x2e82, 0x22b8, Moto G (ID2), Motorola

I can then mount the MotoG's storage with

$ jmtpfs ~/Android_transfer/Unable to open ~/.mtpz-data for reading, MTPZ disabled.Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).Android device detected, assigning default bug flags$ ls -al ~/Android_transfer/total 4drwxr-xr-x 3 me me 0 Dec 31 1969 .drwxr-xr-x 50 me me 4096 Apr 5 21:09 ..drwxr-xr-x 12 me me 0 Oct 2 4448648 Internal storage$ ls -al ~/Android_transfer/Internal\ storage/total 0drwxr-xr-x 12 me me 0 Oct 2 4448648 .drwxr-xr-x 3 me me 0 Dec 31 1969 ..drwxr-xr-x 2 me me 0 Aug 31 2024 Alarmsdrwxr-xr-x 3 me me 0 Aug 26 2014 Androiddrwxr-xr-x 3 me me 0 Feb 13 19:50 DCIMdrwxr-xr-x 2 me me 0 Aug 31 2024 Downloaddrwxr-xr-x 2 me me 0 Aug 31 2024 Moviesdrwxr-xr-x 2 me me 0 Aug 31 2024 Musicdrwxr-xr-x 2 me me 0 Aug 31 2024 Notificationsdrwxr-xr-x 2 me me 0 Aug 31 2024 Picturesdrwxr-xr-x 2 me me 0 Aug 31 2024 Podcastsdrwxr-xr-x 2 me me 0 Aug 31 2024 Ringtones

... and unmount the MotoG's storage with

$ fusermount -u /home/me/Android_transfer$ ls -al ~/Android_transfer/Internal\ storage/ls: cannot access /home/me/Android_transfer/Internal storage/: No such file or directory

failed jmtpfs mount

I initially tried to mount the MotoG using sudo. Don't do that! You'll get results like

$ sudo jmtpfs ~/Android_transfer/Unable to open ~/.mtpz-data for reading, MTPZ disabled.Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).ignoring libusb_claim_interface() = -6PTP_ERROR_IO: failed to open session, trying again after resetting USB interfaceLIBMTP libusb: Attempt to reset deviceAndroid device detected, assigning default bug flags$ ls -al ~/Android_transfer/ls: cannot access /home/me/Android_transfer/: Permission denied$ sudo ls -al ~/Android_transfer/ls: cannot access /home/me/Android_transfer/: Permission denied$ sudo fusermount -u /home/me/Android_transfer

Remember: MTP filesystems are implemented as FUSE, which means Filesystem in your Userspace.

copy files off your smarphone with mtp-getfile

First install the mtp-tools package:

$ sudo apt-get install mtp-tools

Then get the list of available files:

$ mtp-files > file_list.txt

file_list.txt will now contain entries like this:

File ID: 81 Filename: WP_20161029_16_26_49_Pro.jpg File size 936160 (0x00000000000E48E0) bytes Parent ID: 12 Storage ID: 0x00010001 Filetype: JPEG file

where 'Parent ID' is something like the folder where the file resides on the smartphone. So you'll want to do something like this to get that particular file:

mkdir '12'mtp-getfile '81' '12/WP_20161029_16_26_49_Pro.jpg'

Yes, the mkdir '12' and the 12 from the Parent ID in the local file is important.

MTP with a windows phone on Jessie/KDE

This has been tested with a Lumia 530 with Windows Phone 8.1

  • First, to have the Lumia correctly detected in KDE, you have to update your libmtp packages to the ones in 'debian backports'. Right now, in jessie we have libmtp 1.1.8 which is not sufficient to detect the Lumia. in Backports you have 1.1.10 which detects the phone correctly
  • Then, to be able to browse the phone in KDE, you need to install 'kio-mtp' package. In jessie it is version 0.75+git20140304 . But with the version in jessie you will face the following issue in Dolphin 'mtp:udi=/org/kde/solid/udev/sys/... does not exist'. To get that fixed, you need to recompile yourself the package with the patch from https://bugs.kde.org/show_bug.cgi?id=325335. I backported that patch and sent it back to that kde bugreport in case someone is interested.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Ubuntu下U盘变成只读的解决方法
【转】linux Centos 6.5 安装桌面环境GNOME
adb打开关闭
Mount Google Nexus 4 on Ubuntu/Linux Mint/and Ubuntu derivatives
android DDMS工具的正确使用方法
Android uiautomator 使用入门官方教程
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服