Saturday, November 22, 2014

Accessing Android Device partition from Linux OS

apt-get install mtpfs libfuse-dev libmad0-dev
And now download the mtpfs debian package from


wiz@cb-DOC:~# apt-cache search -f mtp-tools
Package: mtp-tools
Description-md5: b21df6970cd0c308c870019c053e3080
Description-en: Media Transfer Protocol (MTP) library tools
 libmtp is a library for communicating with MTP aware devices in POSIX
 compliant operating systems.  It implements MTP Basic, the subset
 proposed for standardization.
 .
 The Media Transfer Protocol (commonly referred to as MTP) is a devised
 set of custom extensions to support the transfer of music files on
 USB digital audio players and movie files on USB portable media players.
 .
 This package contains tools for communicating with MTP devices.

Here's what the libraries intend 
wiz@cb-DOC:~# apt-cache search -f libfuse-dev 
Package: libfuse-dev
Description-md5: da11b1a71c864509638e23fbce6723a3
Description-en: Filesystem in Userspace (development)
 Filesystem in Userspace (FUSE) is a simple interface for userspace programs to
 export a virtual filesystem to the Linux kernel. It also aims to provide a
 secure method for non privileged users to create and mount their own filesystem
 implementations.
 .
 This package contains the development files.


Package: libmad0-dev
Description-md5: bf2478178701150aac144fa1b8a3ff5f
Description-en: MPEG audio decoder development library
 MAD is an MPEG audio decoder. It currently only supports the MPEG 1
 standard, but fully implements all three audio layers (Layer I, Layer II,
 and Layer III, the latter often colloquially known as MP3.)
 .
 This is the package you need to develop or compile applications that use MAD.

And we have one more package which is mtpfs filesystem, which can be downloaded from https://packages.debian.org/sid/amd64/mtpfs/download or you can enable the Testing SID repos and you can fetch it from. 
apt-get install mtpfs

wiz@cb-DOC:~# apt-cache search -f mtpfs
Package: jmtpfs
Description-md5: 05e78b7506b9ac6b1d84a446189e832e
Description-en: FUSE based filesystem for accessing MTP devices
 jmtpfs is a FUSE and libmtp-based filesystem for accessing MTP (Media Transfer
 Protocol) devices. It was specifically designed for exchanging files between
 Linux (and Mac OS X) systems and newer Android devices that support MTP but
 not USB Mass Storage.
 .
 The goal is to create a well-behaved filesystem, allowing tools like find and
 rsync to work as expected. To enable certain Android apps to detect and use
 the transferred files, MTP file types are set automatically based on file
 contents using libmagic.

Package: mtpfs
Description-md5: 587c52dadb2cdcd42b55b3a80018a714
Description-en: FUSE filesystem for Media Transfer Protocol devices
 MTPfs is a FUSE filesystem that supports reading and writing from MTP (Media
 Transfer Protocol) devices, such as MP3 players, video players or digital
 cameras.
 .
 In addition to revealing media files on the connected device, MTPfs exposes a
 virtual directory called "/Playlists" which contains the device's playlists as
 m3u files.


mkdir /media/Mi-DOC

username=wiz

usermod -aG fuse $username

wiz@cb-DOC:~$ grep fuse /etc/group
fuse:x:103:wiz


wiz@cb-DOC:~$ mtpfs /media/Mi-DOC
Listing raw device(s)
Device 0 (VID=2717 and PID=0360) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
   Found 1 device(s):
   2717:0360 @ bus 2, dev 5
Attempting to connect device
PTP_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
Listing File Information on Device with name: (NULL)

wiz@cb-DOC:~$ ls -ltd /media/Mi-DOC/
drwxrwxrwx 2 wiz wiz 0 Jan  1  1970 /media/Mi-DOC/

Now you can access your phone storage..

After you are done accessing your phone make sure you unmount the directory

fusermount -u /media/Mi-DOC

If not then you may face issues while trying to mount again..

wiz@cb-DOC:~$ mtpfs /media/Mi-DOC
Listing raw device(s)
Device 0 (VID=2717 and PID=0360) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
   Found 1 device(s):
   2717:0360 @ bus 2, dev 4
Attempting to connect device
PTP_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
Listing File Information on Device with name: (NULL)
fuse: bad mount point `/media/Mi-DOC': Transport endpoint is not connected

This script can be found at https://github.com/rrskris/mtp-mount

Happy Mounting your Android :)

No comments:

Post a Comment