April 1, 2020

How do I get photos off my phone - MTP (Samsung S4, 2020)

It is surprising how difficult this is. I am running Fedora linux. What I wish I could do is to grab a USB cable, connect it to my linux desktop, and have the phone appear as a mass storage device.
That would be too easy.

The MTP protocol seems to be the thing. On my Fedora 30 system, I do this:

su
dnf install simple-mtpfs
Fooling around with it:
simple-mtpfs  mountpoint [options] (this is the usage message)
simple-mtpfs -h (gives help)
simple-mtpfs -l (lists devices)
With my Samsung S4 connected via a USB cable, I get:
simple-mtpfs -l
1: SamsungGalaxy models (MTP)
The github page for this gives better documentation than the usage message. Source is completely misleading and optional. If you only have one possible device (like I do), you ignore that and just supply a mount point as in:
cd
mkdir mtp
simple-mtpfs ./mtp
....
fusermount -u ./mtp
Note the "fusermount" command to unmount the device. The simple-mtpfs software works with "fuser", which is a driver that supports a user filesystem, for better or worse.

If you had multiple devices (which seems highly unlikely, but who knows, maybe you want to copy files from one phone to another or something), you would use:

simple-mtpfs --device 1 ./mtp
But never mind all of this, the simple command works and I see stuff mounted under ./mtp -- and no need in my case to fiddle any settings on my phone or answer dialogs. There was a long delay waiting for my phone show up and my Fedora desktop briefly showed a useless icon about a Verizon phone.

The trick now is finding my photos (which is what I want in this case) in the mounted directory structure. There are two directories, "Phone" and "Card". Pictures does not have what I want. However each of these has a DCIM directory.

I like to have any commands I won't remember after a week in a Makefile. Then I can just go to a directory, find a Makefile there, look at it, and be back on the air without hassle. So I set up this simple Makefile:

# mount and unmount phone

list:
	simple-mtpfs -l

mount:
	simple-mtpfs /home/tom/Phone/mtp

umount:
	fusermount -u /home/tom/Phone/mtp

pull:
	rsync -av mtp/Phone/DCIM/Camera/ Camera
So, all my phone related stuff (including the mount point) is in the Phone directory on my linux machine.

Note that I added a "make pull" command to pull any new photos off of my phone and maintain a mirror of my phone photos on my linux machine.

So now the scheme to pull photos off my phone is:

-- connect the phone with a USB cable
cd Phone
make mount
make pull
make umount

Have any comments? Questions? Drop me a line!

Tom's Cell Phones / tom@mmto.org