How to mount Android (MTP)-Storage on Linux (openSuSE 12.1)
Published on July 27th 2012 — Listed in Android Linux
While connecting my Android phone (Samsung Galaxy S2, GT-I9000) to my Linux machine, running openSuSE 12.1, I got a bit disappointed, that the Android Storage is not detected automatically.
Android devices use MTP (Media Transfer Protocol) as the way to present the phone to a computer. The first devices which started that were some MP3 players (not iPods though!) and it is slowly becoming the new standard and replacing the «USB Mass Storage» mode. So much to some educational theory. Let’s get to practice.
Back in the year 2010, Mr. Chris Debenham was probably frustrated as I am and decided to program mtpfs, a way to mount such MTP devices using libmtp.
The following steps explain how mtpfs can be installed on Linux (here openSUSE 12.1) and how you mount (and unmount) the MTP storage.
1. Get the source code from Chris’ website:
2. Install dependencies for mtpfs.
Most of them are easy to install by using zypper:
# zypper install gcc
# zypper install fuse-devel
# zypper in libmtp-devel
# zypper in glib2-devel
# zypper in libid3tag-devel libid3tag
Another dependency is mad (libmad) but in openSUSE 12.1 this package is marked as unstable, therefore cannot be installed (by default) with zypper. As a workaround, one can download the rpm directly from the opensuse.com website. Don’t forget to get libmad0 and libmad0-devel RPM’s:
# wget http://download.opensuse.org/repositories/home:/mad_soft/openSUSE_12.1/x86_64/libmad-devel-0.15.1b-12.1.x86_64.rpm
# wget http://download.opensuse.org/repositories/home:/mad_soft/openSUSE_12.1/x86_64/libmad0-0.15.1b-12.1.x86_64.rpm
# rpm -ivh libmad*
warning: libmad-devel-0.15.1b-12.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID a795155b: NOKEY
Preparing. ########################################### [100%]
1:libmad0 ########################################### [ 50%]
2:libmad-devel ########################################### [100%]
3. Compile and install mtpfs:
# ./configure —prefix=/usr -sysconfdir=/etc
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking for a BSD-compatible install. /usr/bin/install -c
checking whether build environment is sane. yes
checking for a thread-safe mkdir -p. /bin/mkdir -p
checking for gawk. gawk
checking whether make sets $(MAKE). yes
checking for gcc. gcc
checking whether the C compiler works. yes
checking for C compiler default output file name. a.out
checking for suffix of executables.
checking whether we are cross compiling. no
checking for suffix of object files. o
checking whether we are using the GNU C compiler. yes
checking whether gcc accepts -g. yes
checking for gcc option to accept ISO C89. none needed
checking for style of include used by make. GNU
checking dependency style of gcc. gcc3
checking whether gcc and cc understand -c and -o together. yes
checking for pkg-config. /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0. yes
checking for FUSE. yes
checking for MTP. yes
checking for GLIB. yes
checking for MAD. yes
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
# make
gcc -DPACKAGE_NAME=\»MTPfs\» -DPACKAGE_TARNAME=\»mtpfs\» -DPACKAGE_VERSION=\»1.1\» -DPACKAGE_STRING=\»MTPfs\ 1.1\» -DPACKAGE_BUGREPORT=\»Chris\ Debenham\ \ \» -DPACKAGE_URL=\»\» -DPACKAGE=\»mtpfs\» -DVERSION=\»1.1\» -DDEBUG=0 -I. -DFUSE_USE_VERSION=22 -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libusb-1.0 -DUSEMAD -g -O2 -MT mtpfs-mtpfs.o -MD -MP -MF .deps/mtpfs-mtpfs.Tpo -c -o mtpfs-mtpfs.o `test -f ‘mtpfs.c’ || echo ‘./’`mtpfs.c
mv -f .deps/mtpfs-mtpfs.Tpo .deps/mtpfs-mtpfs.Po
gcc -DPACKAGE_NAME=\»MTPfs\» -DPACKAGE_TARNAME=\»mtpfs\» -DPACKAGE_VERSION=\»1.1\» -DPACKAGE_STRING=\»MTPfs\ 1.1\» -DPACKAGE_BUGREPORT=\»Chris\ Debenham\ \ \» -DPACKAGE_URL=\»\» -DPACKAGE=\»mtpfs\» -DVERSION=\»1.1\» -DDEBUG=0 -I. -DFUSE_USE_VERSION=22 -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libusb-1.0 -DUSEMAD -g -O2 -MT mtpfs-id3read.o -MD -MP -MF .deps/mtpfs-id3read.Tpo -c -o mtpfs-id3read.o `test -f ‘id3read.c’ || echo ‘./’`id3read.c
mv -f .deps/mtpfs-id3read.Tpo .deps/mtpfs-id3read.Po
gcc -g -O2 -o mtpfs mtpfs-mtpfs.o mtpfs-id3read.o -pthread -lfuse -lrt -ldl -pthread -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -L/lib64 -lmtp -lusb-1.0 -lmad -lm -lid3tag
# make install
make[1]: Entering directory `/root/src/mtpfs-1.1′
test -z «/usr/bin» || /bin/mkdir -p «/usr/bin»
/usr/bin/install -c mtpfs ‘/usr/bin’
make[1]: Nothing to be done for `install-data-am’.
make[1]: Leaving directory `/root/src/mtpfs-1.1′
4. Connect your Android phone with USB cable. Make sure you disable the ‘USB Debug Mode’ (also called Android Debugging).
5. Mount the Android storage using mptfs. Note there is no device you need to tell the mtpfs command.
# mkdir /mnt/android
# mtpfs /mnt/android/
Listing raw device(s)
Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
Found 1 device(s):
Samsung: GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note (04e8:6860) @ bus 2, dev 5
Attempting to connect device
ignoring usb_claim_interface = -99Android device detected, assigning default bug flags
Reading in zero packet after header
Reading in zero packet after header
Reading in zero packet after header
Listing File Information on Device with name: (NULL
With df you can check the new mount point:
# df -h | grep mtp
mtpfs 12G 6.5G 5.1G 56% /mnt/android
6. Access the MTP storage. You can read files, copy files to the storage etc.
# ls /mnt/android/
Internal Storage Playlists
# cp /home/ckuenzler/Downloads/cm-9-20120726-NIGHTLY-galaxys2.zip /mnt/android/Internal\ Storage/
7. Unmount:
# fusermount -u /mnt/android
Update August 20th 2012:
After some tests I figured out that this MTP mount with mtpfs works only once after a reboot. Any additional mounts after an unmount or unplug of the Android device will fail. See comments for more details and error messages.
Update January 9th 2013:
I’m meanwhile on openSuSE 12.2 and this still doesn’t work properly. I gave jmtpfs a shot, which works fine the first mount, too. But again, after a umount and another mount, the following errors appear:
# jmtpfs /mnt/android/
Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
ignoring usb_claim_interface = -99PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
ignoring usb_claim_interface = -99LIBMTP PANIC: failed to open session on second attempt
terminate called after throwing an instance of ‘MtpErrorCantOpenDevice’
what(): Can’t open device
Aborted
Add a comment
Comments (newest first)
dominobet from wrote on Oct 13th, 2014:
yh from SG wrote on Jan 30th, 2013:
Thanks for taking time to share this. At least now I can use mtpfs to mount the phone and copy content in/out.
Alexander from Schweiz wrote on Nov 5th, 2012:
I use Ubuntu and never got MTP to work flawlessly enough to be useful for me.
For that reason, I «switched» to using «adb» for all my file transfer needs. On the command line. In the year 2012.
We’re making quite some progress in usability, aren’t we. :/
Sandra from Germany wrote on Sep 1st, 2012:
Using Linux Mint 13, I am able to mount and umount my android device several times without rebooting. Also, I installed mtpfs via the repositories and did not compile it myself.
libusb is version 1.0.9
rc3-2ubuntu1 and libfuse is 2.8.6-2ubuntu2.
Claudio from Switzerland wrote on Aug 20th, 2012:
Hello Florian,
It is indeed the case: The mtpfs mount works only once after a reboot. After a fusermount -u (unmount) and another try to mount with mtpfs, the following error messages appear:
Attempting to connect device
ignoring usb_claim_interface = -99PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
ignoring usb_claim_interface = -99LIBMTP PANIC: failed to open session on second attempt
Unable to open raw device 0
It only works again after a reboot of the machine.
I completely agree: This is crap and _almost_ useless.
Claudio from Wil, Switzerland wrote on Aug 18th, 2012:
I am having issues to mount the Android storage now too. I’ve tried to mount the SGS2 several times on Friday, without success. Something crossed my mind: Once mounted with mtpfs, it won’t work anymore until a reboot. Will try that on Monday and will let you know.
Florian from Germany wrote on Aug 18th, 2012:
Sorry for the late Answer, i didn’t have time before.
Yes, I am using openSuSE 12.1, too.
My Versions of libfuse and libusb are the same as yours. Turning on or off USB Debugging Mode don’t make any difference, it doesn’t work at all. I can’t believe that I have to use Windows to access an Android Phone (Linux Kernel. )
That is such a crap!
A few minutes ago, I also tried to login as root. Nevertheless it didn’t work.
Claudio from Switzerland wrote on Aug 15th, 2012:
Important information: You must be root to mount the Android device. Otherwise an error like the following will appear:
libusb couldn’t open USB device /dev/bus/usb/002/003: Permission denied.
You can also run sudo mtpfs /mnt/android to gain sufficient permissions to access the USB device.
Claudio from Switzerland wrote on Aug 8th, 2012:
Are you also using OpenSuSE 12.1?
What’s your libusb and libfuse version?
Mine are:
— libfuse2-2.8.5-16.1.2.x86_64
— fuse-2.8.5-16.1.2.x86_64
— usbutils-004-2.1.2.x86_64
— libusb-1_0-0-1.0.8-9.1.2.x86_64
Also try with USB debugging enabled and once disabled. Always re-connect your USB cable after changing something.
In my case I also had to do a reboot when I upgraded my kernel and this had probably an impact on loaded kernel modueles.
Florian from Germany wrote on Aug 8th, 2012:
When I tried to mount my Samsung Galaxy S3 in this way, I got the following message:
> mtpfs /home/Florian/Arbeitsfläche/test/
Listing raw device(s)
libusb couldn\\\’t open USB device /dev/bus/usb/008/002: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn\\\’t open USB device /dev/bus/usb/002/002: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn\\\’t open USB device /dev/bus/usb/008/003: Permission denied.
libusb requires write access to USB device nodes.
Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
Found 1 device(s):
Samsung: GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note (04e8:6860) @ bus 1, dev 8
Attempting to connect device
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
LIBMTP PANIC: failed to open session on second attempt
Unable to open raw device 0
Florian@linux-ls4i:
Источник
How To Properly Mount Android 4.0+ Devices In Ubuntu Using Go-mtpfs
Author : Andrew | Posted: December 19, 2012
Video: see Go-mtpfs in action
Below you can watch a video I’ve recorded, demoing Go-mtpfs in Ubuntu 12.10 (as well as the custom Unity launcher / script I’ve created for it):
(direct video link; subscribe to our YouTube channel for more videos)
Install Go-mtpfs in Ubuntu
Update: Gvfs has been updated in Ubuntu 13.04 Raring Ringtail, bringing a new MTP backend which allows users to access Android 4.0 devices which do not support the USB Mass Storage. So this should work out of the box with Raring.
Go-mtpfs is available in the WebUpd8 Unstable PPA, for Ubuntu 13.04, 12.10 and 12.04. Add the PPA and install it using the following commands:
Note: I’ve only tested it in Ubuntu 12.10, using a Samsung Galaxy S II phone (with both Android 4.1 and 4.2.1).
Update 13 February 2013: I’ve backported the latest libmtp from Raring to Quantal and Precise, the update bringing support for some new devices.
Notes:
- Unmounting the device via Nautilus does not work!
- Sometimes you may get an error if the device is locked, so unlock it before trying to mount it;
- When plugging in an Android device via USB, Ubuntu will try to mount it and it’s a good idea to stop this by clicking the unmount icon in Nautilus.
For manual installation instructions, see: THIS post.
Источник
How to connect MTP devices via USB?
How does one connect an MTP device to Ubuntu via USB? Many popular devices, such as all Android 4.0 phone, have only MTP or PTP as a connection option, no USB mass storage anymore.
Considering the popular Samsung S3: connecting as either MTP or PTP: neither allows one to see pictures saved as default by phone camera to DCIM folder on external SD card. Similar problems with previous models (with Android 2.x) were solvable by ‘usb utilities’ in wireless & networking settings, but this is no longer present in Android 4.0.
14 Answers 14
Install gmtp, and use it to connect to the phone or tablet :
Try the «AirDroid» App from Play Store. It allows you to use a browser based interface (on your computer) to transfer files from a Windows/Linux pc. Since it’s browser based UI, no need to install anything on the pc side.
You just install jmtpfs (via sudo apt-get install jmtpfs ). After connecting your phone via USB, enable the MTP file transfer on your phone and it will show up as USB device on your computer. You can then access the whole file system (and not only the pictures, as with PTP) of your Android device.
This worked for me with (K)Ubuntu 14.04 LTS and my Motorola Moto G.
Have a look at this:
Changing from MTP to PTP (camera transfer mode) also works with nautilus, at least with the built-in memory.
I have been able to do this using the following:
Here is the version this worked on:
I haven’t had perfect success with it, but I was able to get some files off of the phone. I imagine this will get better as newer software is released.
There is no GUI needed for file transfer (No One on Ubuntu is interested in making a GUI for only file transfer). And there is no need for plugins for Nautilus either. I Use Samsung Galaxy Mini (Android 2.2
Froyo), and I’m doing file transfer so far by three ways, Bluetooth connection, Cable connection or using Ubuntu One app.
For cable connection you can do it easily as plug the cable, wait a while and choose mass storage mode. Access and File Transfer via Nautilus. If you want to make the phone as modem, go here: http://shiliarr95z.weebly.com/2/post/2011/07/connecting-samsung-galaxy-mini-android-phone-to-ubuntu-1104-as-modem.html.
Using Ubuntu app is the easiest one. On the phone side,just go to Android market and install the Ubuntu one app. photo sharing runs in the background in an instant. On the Ubuntu side, just register yourself on Ubuntu One (click the envelope icon and choose Ubuntu One). And, You Have GUI on the phone side (On the Ubuntu side, you got only an OSD Message)
Источник