How to mount Android (MTP)-Storage on Linux (openSuSE 12.1)

Written by - 10 comments

Published on - 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:

# wget http://www.adebenham.com/files/mtp/mtpfs-1.1.tar.gz

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

Enjoy! :-))

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

Show form to leave a comment

Comments (newest first)

dominobet from wrote on Oct 13th, 2014:

thankz you


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:

Florian@linux-ls4i:~> 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:~>

What did I do wrong?


RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder