Ubuntu – mtp usage: how to mount and transfer files to and from a Samsung: Galaxy model Android phone

androidfilesystemmountsmartphoneusb

how do I use mtpfs to read/write to a USB connected Android phone, connected as a mass storage device:

thufir@dur:~$ 
thufir@dur:~$ mkdir phone
thufir@dur:~$ 
thufir@dur:~$ sudo mtpfs -o allow_other phone
[sudo] password for thufir: 
Unable to open ~/.mtpz-data for reading, MTPZ disabled.Listing raw device(s)
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
   Found 1 device(s):
   Samsung: Galaxy models (MTP) (04e8:6860) @ bus 1, dev 6
Attempting to connect device
ignoring libusb_claim_interface() = -6PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
LIBMTP PANIC: Could not open session! (Return code 8195)
  Try to reset the device.
Unable to open raw device 0
thufir@dur:~$ 

and:

thufir@dur:~$ 
thufir@dur:~$ mount
/dev/mapper/ubuntu--vg-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
/dev/sda1 on /boot type ext2 (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=thufir)
thufir@dur:~$ 

and lsusb shows:

thufir@dur:~$ lsusb
Bus 001 Device 006: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-I9300 Phone [Galaxy S III], GT-P7500 [Galaxy Tab 10.1]
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 003: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 004 Device 002: ID 0461:0010 Primax Electronics, Ltd HP Keyboard
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
thufir@dur:~$ 

Toggling the phone between MTP and PTP allows:

thufir@dur:~$ 
thufir@dur:~$ sudo mtpfs -o allow_other phone
[sudo] password for thufir: 
Unable to open ~/.mtpz-data for reading, MTPZ disabled.Listing raw device(s)
   No raw devices found.
thufir@dur:~$ sudo mtpfs -o allow_other phone
Unable to open ~/.mtpz-data for reading, MTPZ disabled.Listing raw device(s)
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
   Found 1 device(s):
   Samsung: Galaxy models (MTP) (04e8:6860) @ bus 1, dev 8
Attempting to connect device
Listing File Information on Device with name: GT-S7560M
thufir@dur:~$ 
thufir@dur:~$ ls phone 
ls: cannot access phone: Transport endpoint is not connected
thufir@dur:~$ 

although I don't know what that accomplishes.

see also:

https://askubuntu.com/a/57306/45156

Best Answer

I'm on Debian derived Bunsen Labs Linux 8.6 bunsen-hydrogen
So,you can try this:

$ sudo apt-get install mtp-tools
$ man mtp-tools

This is kinda clunky, but I've used it to get files off my ultra low-end Alcatel (KitKat) phone.
There's got to be a better way...

#!/bin/bash
# copies all the pictures out of my Android phone

echo "Creating list of .jpg files..."
mtp-files | \
egrep '^File ID|Filename' | \
perl -pe 'm/^File/ && s/\n//' | \
perl -lane 'print "$F[2] $F[4]" if m/\.jpg/' > camera_files.lst

while read field1 field2; do
  echo "Copying $field2..."
  mtp-getfile $field1 $field2
done < camera_files.lst
Related Question