Differences between revisions 11 and 12
Revision 11 as of 2015-08-23 21:56:26
Size: 7034
Editor: TomRoche
Comment: clarify version of what
Revision 12 as of 2015-09-11 11:18:33
Size: 7226
Editor: ?micsu
Comment: make sure fusermount has write access to <directory>
Deletions are marked like this. Additions are marked like this.
Line 36: Line 36:
  * create <directory> as your mount point: {{{$ mkdir -p <directory>}}}

  * make sure fusermount has write access to <directory>: {{{$ chmod 777 <directory>}}}
Line 38: Line 42:
   * Your screen must be unlocked in order to mount. However, you might get a (spurious) `input/output error` even if the screen is unlocked.    * 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.
Line 40: Line 44:
  * to unmount your device: {{{fusermount -u <directory/>}}}   * to unmount your device: {{{$ fusermount -u <directory/>}}}
Line 50: Line 54:
  * to unmount your device: {{{fusermount -u <directory/>}}}   * to unmount your device: {{{$ fusermount -u <directory/>}}}

MTP -- mounting smartphones (et al) on Debian GNU/Linux

summary

Media Transfer Protocol is used for transfering files (etc) between devices--notably newer Androids.

Graphical User Interface

Package=gvfs-backends enables GVFS (the GNOME virtual file system) to mount MTP volumes. This should allow your filesystem browser (e.g., nautilus) to

  • 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).

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

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

There are various ways to use MTP on the commandline:

  1. mtp-tools

    • install package name=mtp-tools

    • TODO: document usage!

  2. jmptfs

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

    • install package name=jmtpfs

    • create <directory> as your mount point: $ mkdir -p <directory>

    • make sure fusermount has write access to <directory>: $ chmod 777 <directory>

    • to mount your device: $ jmtpfs <directory/>

      • 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 <directory/>

  3. mptfs

    • mtpfs is very similar to jmtpfs, except for the executable name, package name, and package status (mtpfs has been orphaned since squeeze).

    • install package name=mtpfs

    • to mount your device: $ mtpfs <directory/>

    • to unmount your device: $ fusermount -u <directory/>

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_version
jessie/sid
$ uname -rv
3.11-2-amd64 #1 SMP Debian 3.11.8-1 (2013-11-13)
$ gcc --version | head -n 1
gcc (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  100
Package kio-mtp:
Package kio-mtp-dbg:
Package kio-mtp-dbg:i386:
Package kio-mtp:i386:
Package libmtp-common:
i  1.1.8-1  100
Package libmtp-dbg:
Package libmtp-dbg:i386:
Package libmtp-dev:
Package libmtp-dev:i386:
Package libmtp-doc:
i  1.1.8-1  100
Package libmtp-runtime:
i  1.1.8-1+b1  100
Package libmtp-runtime:i386:
Package libmtp9:
i  1.1.8-1+b1  100
Package libmtp9:i386:
i  1.01-3 testing 500
Package mtp-tools:
i  1.1.6-20-g1b9f164-1 testing 500
Package 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 8
drwxr-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 -l
Sun Apr  5 20:08:46 EDT 2015
Unable 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 -l
Sun Apr  5 20:09:06 EDT 2015
Unable 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 4
drwxr-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 0
drwxr-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 Alarms
drwxr-xr-x  3 me me 0 Aug 26  2014 Android
drwxr-xr-x  3 me me 0 Feb 13 19:50 DCIM
drwxr-xr-x  2 me me 0 Aug 31  2024 Download
drwxr-xr-x  2 me me 0 Aug 31  2024 Movies
drwxr-xr-x  2 me me 0 Aug 31  2024 Music
drwxr-xr-x  2 me me 0 Aug 31  2024 Notifications
drwxr-xr-x  2 me me 0 Aug 31  2024 Pictures
drwxr-xr-x  2 me me 0 Aug 31  2024 Podcasts
drwxr-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 interface
LIBMTP libusb: Attempt to reset device
Android 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.