I have an Android phone that connects with my computer via MTP. This works fine; I can see and transfer files with Nautilus. However, I often want to use the terminal to move large numbers of files, and I cannot seem to find the device anywhere in the filesystem tree. Nautilus reports the location as mtp://[usb:003,007]/
, but it's not under /media
or /mnt
.
Does anyone know where it is?
As you have already found out, the mountpoints are in
/run/user/$USER/gvfs/
(or/var/run/user/$UID/gvfs
) and are named after the protocol, connection type and address they use. Which makes things more difficult, because the connection address may change every time you replug the device, even if it is the same port. If you have the same device twice it gets even worse.You can use
lsusb
to display all connected USB devices from terminal:As you have noticed Nautilus also gives this information via tool tip. You will find the encoded form of e.g.
mtp://[usb:002,025]
in/run/user/$USER/gvfs
(or/var/run/user/$UID/gvfs
) asmtp:host=%5Busb%3A002%2C025%5D
Asker's edit: This seems to require a newer version of libmtp and/or gvfs than is available per default in 13.04. Run
sudo add-apt-repository ppa:langdalepl/gvfs-mtp
and update before doing anything else.Edit: PPA not needed anymore in saucy/13.10 and newer, filenames are listed in terminal as they are in Nautilus.
Edit 2016-01-11: I removed the script that was previously included in this answer due to lack of time for maintenance and improvements. You can still find it in the revision history.
My Nexus device's memory can be accessed at:
So if your $UID is
1000
, you may find it by either doingor (for the exact location in an example assuming your UID is 1000),
MTP
mounted device usually can be found in :/run/user/1000/gvfs/
for eg if your Nautilus address bar shows
mtp://[usb:001,006]/
, then you can access by:now on terminal you can copy files or folders:
cd /run/user/1000/gvfs/mtp\:host=%5Busb%3A001%2C006%5D/
cp -r ~/videos/ .
I got an LG2 phone and I am running Xubuntu 15.10.
This is how I mounted the device to mnt directory in under my user.
First make sure you have the following packages installed in your system.
Connect your phone as MTP device and type the following command in your terminal.
Uncomment
user_allow_other
in file/etc/fuse.conf
.Create a directory
mnt
in your home directory.Mount the device.
Thats it. Now your device is mounted under the
mnt
directory created in step 4.Note: There may be some steps that are unnecessary. But following the above steps worked for me.
Reference: https://wiki.archlinux.org/index.php/MTP
This is working with:
Try this:
apt-get install mtpfs
apt-get install mtp-tools
#
yes could be one line (this is optional)sudo mkdir -p /media/mtp/phone
sudo chmod 775 /media/mtp/phone
#
Personally I'd restrict permissions to NO-eXecute#
At this point I'm not sure what is enough to mount.sudo mtpfs -o allow_other /media/mtp/phone
ls -lt /media/mtp/phone
Output:
ls -lt /media/mtp/phone/Card
Output:
Listing access to the SD-card on my Android phone. "Playlists" is a virtual directory called "/Playlists" which contains your playlists as .m3u files. (per
man mtpfs
)That seems to do the trick. Useful commands to remember ...
sudo mtpfs -h
... lists the device's options. This seems to only work before you have mounted the device. So check first-off, perhaps.mtp-detect
... shows lots of stuff about the device (part of mtp-tools).Also, I think you need the phone/device "on", open the screen-saver if you have one so the device can connect.
I noticed that my USB-s mount as:
So it might make more sense to mount under your username instead of the "mtp" stub. Also, review the post: "Mounting Your MTP Androids SD-card on Ubuntu", it has a few useful suggestions and extras.
References
I took my lead from these two posts:
Type
mount
. That will list every active filesystem.I don't know exactly to traverse to MTP location via terminal. However, I found out that we can right click on the Internal storage / SD card and choose option "Open in Terminal". Doing so the location is directly opened in Terminal.
This is not a direct answer to the problem, but a solution nonetheless.
After experiencing inconsistency's with USB connectivity, I bypassed the .gvfs and USB system all together.
I installed a simple ftp server on the android and voila! Connect to server (either ftp with login or without, depending on how you choose) from Nautilus/nemo/thunar and away you go.
Syncronisation of folders is handled through OwnCloud and/or BitTorrentSync.
And the FTP over wireless is way quicker than the USB connection was.
MTP is a protocol, much like FTP or SSH. It fetches files when the user asks for it. Thus there is no mounted file system on the computer.
Use mtpfs in order to make it appear like a mounted file system.
No need to specify the device. If you have only one device connected, then there is no ambiguity. I have not tested it with multiple devices connected to my computer.
After accessing the correct path as said HERE and other answers, a good idea is to add the invariable path (for example
/run/user/1000/gvfs
) as a bookmark to the file manager left panel. When phone is disconnected, that folder will be empty.I have noticed that there is a difference between the options available for a file accessed in this way and those available for the same file when accessed the "normal" way, by the
mtp://
path (clicking "mtp" or the device name/numbers on the left panel): when accessed by/run/user/.../gvfs
the file has in context menu ("Open with") all the expected options; these options are limited (reduced to default/vanilla ones) when the file is accessed bymtp://
. Also, some programs (e.g. MKVToolNix) cannot access a file by themtp://
path, but they can by the other one. This aspect may become important is some scenarios, like for example when one needs to create/download a file on the phone, process it through a computer program (e.g. MKVToolNix) and output it on an external device.