Connecting Centos 7 to Android phone

jayuu picture jayuu · May 3, 2017 · Viewed 10.3k times · Source

I'm trying to connect a Centos 7 operating system to a Moto3G Android phone (running Android v6 - marshmallow)

libmtp is installed

Package libmtp-1.1.6-5.el7.x86_64 already installed and latest version
Nothing to do

Most of the searches on the Internet suggest using mtp-detect but in my case:

bash: mtp-detect: command not found

I can see the phone using dmesg

[ 6446.771306] usb 1-1.2: Product: XT1039
[ 6446.771309] usb 1-1.2: Manufacturer: motorola

I installed jmtpfs (using yum) which gives me the following

jmtpfs
No mtp devices found.

I tried installing go-mtpfs using GO but get the following

$ ./gopath/bin/go-mtpfs bob &
[1] 21633
$ 2017/05/03 13:06:18 detect failed: no MTP devices found

[1]+  Exit 1                  ./gopath/bin/go-mtpfs bob

If anyone has any advice or suggestions on progressing this I'd be grateful.

Answer

vinod bherwal picture vinod bherwal · Sep 30, 2017

Access Android MTP or Other MTP devices in CentOS 7 Linux OS

Install mtp libs and utilities in CentOS

Login as root and install fuse, jmtpfs, libmtp as following:

$yum install fuse, jmtpfs, libmtp

Steps to Mount/Load MTP formatted devices(e.g android 7 nougat)

Login as root Create a directory to mount MTP device:

$mkdir /media/mtp-device 

Connect android device to the USB cable, Unlock the android phone, Swipe down from the top of the phone screen. You should see a notification "USB ...", Tap that notification. You should see a menu titled "Use USB to...", select "Transfer files(MTP)" Option...

To list all the available mtp devices(eg. android 7 nougat), issue command jmtpfs in root session

$jmtpfs -l

each mtp device is listed with busnum, devnum information. Mount device as below:

$jmtpfs -device=<busnum>,<devnum> /media/mtp-device #If this option not specified, then the first device found isused. 

or

$jmtpfs /media/mtp-device #All files will be present in /media/mtp-device location,but it will be accessible to the root only.

2. Access/Copy Data from MTP device

Now you can access files of android devices mounted on /media/mtp-device folder, but you cannot copy to other folder. To copy files, you need to allow other user as below:

$jmtpfs -o allow_other ~/my-android7 

Now you can copy the data from ~/my-android7 location to your folders.

3. Removing or Un-mounting the Device from Linux System

First un-mount the allow_other location

$fusermount -u ~/my-android7

Finally un-mount the device at root folder.

$fusermount -u /media/mtp-device