Mount mtp in linux

Media Transfer Protocol

The Media Transfer Protocol (MTP) can be used to transfer media files to and from many mobile phones (all Windows Phone 7/8/10 devices, most newer Android devices) and media players (e.g. Creative Zen).

Contents

Connecting

To connect your computer to a device via MTP:

  • the device needs to be connected to your computer via USB
  • MTP needs to be enabled on the device
  • the device’s screen needs to be unlocked (for security reasons)

FUSE filesystems

The following programs let you access MTP devices via a FUSE filesystem.

For the FUSE-based file systems, you might need to create the mount-point directory first. The directory

/mnt is used in the examples below.

FUSE mounts can generally be unmounted using fusermount -u mountpoint .

Android File Transfer

Android File Transfer — MTP client with CLI, Qt UI, and FUSE wrapper which uses a custom MTP implementation

Mount your device on

If you want album art to be displayed, it must be named albumart.xxx and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.

If you want to interact with it via the command line interface, run the command:

Type help in order to list all the commands available, exit to quit.

If you want to interact with it via the graphical user interface, start the android-file-transfer application, choose a destination folder and click any button on the toolbar. Available options are: Upload Album, Upload Directory and Upload Files. The latter two are self-explanatory. Upload album searches the source directory for album covers, and sets the best available cover.

MTPfs

MTPfs — based on libmtp, it is a FUSE filesystem that supports reading and writing from any MTP device

First edit your /etc/fuse.conf and uncomment the following line:

Mount your device on

jmtpfs

jmtpfs — based on libmtp for accessing MTP (Media Transfer Protocol) devices

Mount device on

Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps

add this line to /etc/fstab ;

Now mount the device and see if the options «took»

SIMPLE-MTPFS

SIMPLE-MTPFS — based on libmtp Simple Media Transfer Protocol FileSystem is a file system capable of operating on files on MTP devices attached via USB to local machine

Run simple-mtpfs -l to list detected devices.

To mount the first device in the list to

/mnt , run simple-mtpfs —device 1

go-mtpfs

go-mtpfs — FUSE filesystem with custom MTP implementation, written in Go

Install android-udev , which will allow you to edit /etc/udev/rules.d/51-android.rules and apply to your idVendor and idProduct , which you can see after running mtp-detect. To the end of the line, add your user OWNER=» » .

Mount device on

libmtp

libmtp is a library MTP implementation, which also comes with some example command-line tools (which you can list using pacman -Ql libmtp ).

Run mtp-detect to detect your device.

If an error is returned, make sure your user is in the uucp user group.

You can transfer files using the mtp-connect command.

Frontends

gMTP — A graphical frontend for libmtp. It lets you connect to Android devices and manage files using a desktop agnostic GUI.

Media players

You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit /etc/udev/rules.d/51-android.rules (the MTP device used in the following example is a Galaxy Nexus). Run:

Читайте также:  Canon lbp 810 driver windows 64 bit

Search for your device. It should be something like that:

And entry to /etc/udev/rules.d/51-android.rules will be this:

Also reload udev rules:

File manager integration

To view the contents of your Android device’s storage via MTP in your file manager, install the corresponding plugin:

  • For file managers that use GVFS (GNOME Files), install gvfs-mtp for MTP or gvfs-gphoto2 for PTP support.
  • For file managers that use KIO (KDE’s Dolphin), MTP support is included in kio-extras (dependency of dolphin).

After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example mtp://[usb:002,013]/ .

gvfs-mtp

This article or section is a candidate for merging with udev.

The gvfs-mtp is available in the official repositories.

With lsusb you can get information about your device where Bus and Device numbers can be used with gvfs-mtp and device ID for creating of an udev rule.

To see detected device with enabled MTP

To mount all available connected MTP devices use inline script

To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount gio mount mtp://[usb:001,007]/ and to unmount gio mount -u mtp://[usb:001,007]/ . The mounted device will be available in a directory that begins with mtp:host= and is located under /run/user/$UID/gvfs/.

Disable automount of MTP devices with gvfs you will need to change value true to false for variable AutoMount that is located in /usr/share/gvfs/mounts/mtp.mount .

If your device is not showing up in the file manager then #libmtp is missing a native support and is not currently available in the list of the supported devices. If you will try to mount by using command line you may also get an error

The workaround to make it shown in the file manager is to write an udev rule for the device but it is no guaranty that you will be able to mount it with by using MTP connection.

Use ID number that represents by pattern vendorId:productID,e.g. 04b7:88a9, and make an udev rule by creating a configuration file

Reload the udev rules.

The file managers with support for gvfs will be able to show MTP devices and mount them if supported by #libmtp but if has no support and cannot be opened then change settings in the phone to PTP and install gvfs-gphoto2 for having access at least to the photos, command line mounting of PTP is a little similar to mounting of the MTP devices: gio mount gphoto2://[usb:002,019]/ .

Troubleshooting

libmtp (gvfs-mtp): filemanager (nautilus, pcmanfm, vifm and etc) hangs on accessing DCIM/Camera of Android device

Symptoms: everything works fine till moment of entering DCIM/Camera directory. In this case filemanager freezes and even in command line you cannot run even ls on that directory.

Possible and very probable reason is the bug of libmtp.

It seems that it is caused by file with name like 20180915_180351(0).jpg . Samsung phones for example like to create files with such names.

There are several tickets (one, two and etc) and questions (one, two) about it.

So possible workaround is to use different mtp option from #FUSE filesystems like go-mtpfs for such directories or somehow change file naming policy of your phone camera (or switch to another camera app like Open Camera for example).

jmtpfs: Input/output error upon first access

Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via ls ), an error is reported:

This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.

kio-mtp: cannot use «Open with File Manager» action

If you are not able to use the action «Open with File Manager», you may work around this problem by editing the file /usr/share/solid/actions/solid_mtp.desktop .

Читайте также:  Windows android usb device driver

Change the line Exec=kioclient exec mtp:udi=%i/ to Exec=dolphin «mtp:/» .

kio-mtp being called simultaneously by different services

Parallel usage of mtpfs and kio-mtp, as well as conflicting services using kio-mtp -music players included- should be avoided, as mentioned in this forum.

Amarok’s plugin for MTP services, for example, might be preventing Dolphin (plasma) to access different phone model’s files. Switching it off was a solution for at least one user.

Android File Transfer: connect failed: no MTP device found

After installing android-file-transfer , while trying to mount any MTP device if you get the following error:

then install the package: android-udev . This package contains per manufacturer/device udev rules for MTP devices, making it easier to use ADB or MTP.

Источник

Android MTP и Linux

Добрый день. Как вы работаете с android устройствами, подключающимися по протоколу MTP(в которых нет возможности подключиться в качестве обычного usb накопителя)? В Kubuntu 16.04 данные устройства определяются и можно скопировать данные. Но копирование крайне нестабильно. То обрывается ошибкой копирования, то вообще висит и список файлов не выводит. А как с этой чудо технологией работаете вы?

У меня в Debian 9 Xfce поставлены пакеты libmtp9 и gvfs-backends, thunar норм подхватывает. Проблемы с отваливанием были, но я заменил USB кабель и они исчезли.

Лучше всего установить SSHDroid (работает даже без рута), и копируй что хочешь хоть по WiFi, хоть по usb шнурку, подключив телефон в режиме модема, через sshfs.

MTP — ублюдочная технология дурацкого мелкософта. Не работает нормально порой даже в винде. В KDE из коробки работает, да, но это феерическое глюкалово и выкобелилово.

Android File Transfer наиболее стабильный ИМХО. Но лучше вместо MTP использовать sshfs (KDE Connect для удобного подключения) или FTP (свободный файловый менеджер Amaze поволяет поднять сервер).

ага, вот как раз amaze спасаюсь. но и он иногда падает.

В Kubuntu 16.04 данные устройства определяются и можно скопировать данные. Но копирование крайне нестабильно. То обрывается ошибкой копирования, то вообще висит и список файлов не выводит.

В Windows оно работает точно также. Это не зависит от ОС.

Поставь себе kdeconnect и не мучайся.

Не то чтобы так же, в целом лучше. Но иногда появляются дебильные баги, типа ошибок чтения или записи. Иногда спасает плагин к тоталкоммандеру, который тоже по своему глючен.

В Kubuntu 16.04 данные устройства определяются и можно скопировать данные. Но копирование крайне нестабильно. То обрывается ошибкой копирования, то вообще висит и список файлов не выводит. А как с этой чудо технологией работаете вы?

Тоже мучаюсь, тоже KDE. Но это не важно, на Win10 такие же баги с MTP.

Пару раз из-за того, что каталог /sdcard1 каким-то чудном образом в этом MTP попадал в корень флеш-карты, я терял данные.

В итоге ушел на ADB Pull/Push и доставалку файлов из Android Studio.

Ужасная хрень. Ужасная.

И да, для kde-хейтеров есть похожая софтина на gtk, только вот название подзабыл.

Зачастую проще через дропбокс туда файлы заливать. Или не заливать, а использовать тот же дропбокс. Я только стратегический запас музыки для поездок за бугор, где нет интернета, храню. А так шарах из дропбокса файл и все.

Нет, все так и есть.

Не замечаю разницы. Везде использование MTP для доступа через файловый менеджер несет боль и страдания.

у меня тоже с MTP была проблема. именно из-за конкретного телефона. То есть эти проблемы с бОльшей вероятностью проблема девайса самого, а не компа.

Плюсую xmikex .

На своём аппарате проблем с MTP ни на онтопике, ни тем более на оффтопике не имел.

Копируй по сети. Зачем тебе тормозной МТП?

У тебя плохой усб кабель -100%

MTP убог, я гоняю файлы через rsync поверх SSH.

Умвр и под линаксом.

Сколько раз копировал — не подводило, что под вендой, что под линуксами.

Висело только один раз и под вендой. Очень смешно система повела себя при копировании файла размером в 6GB (флешка была в FAT32 с лимитом в 4GB). Ползунок просто завис на 4GB, и не ошибки и ничего, как будто процесс продолжается 😀 (на линуксе подобное не пробовал)

Читайте также:  Wallpapers from mac os big sur

Атенсьён! Поганный вантузятник на борту! Срочно сбросить его в винфак!

Отваливается, когда либо шнур плохой, либо штекер в гнезде не плотно сидит.

Пробовал разные кабели. Результат один.

Попробуй разные материнские платы.

мой глючит рандомно, возможно из за самого телефона.
Плюнул, поставил «root ftp server» и «samba filesharing for android» и по wifi. Хотя если единоразово скачать, то можно и MTP.

А как с этой чудо технологией работаете вы?

Беру кабель, один конец подключаю к прямоугольнику с скруглёнными краями, второй — к шайтан-машине. Потом беру указатель типа «мышь», нажимаю на значок с папкой, выбираю в списке устройств свой прямоугольник с скруглёнными краями, после чего движениями указателя типа «мышь» переношу в это окно нужные файлы.

Нет, так как я на кедах сижу и соответственно kdekonnect.

А как с этой чудо технологией работаете вы?

стараюсь всячески избегать.. на маке с официальным Android File Transfer те же грабли.

Через связку mconnect и gnome-shell-extension-mconnect работают только оповещения, статус батареи, remote input и пересылка файлов с мобильного. Найти телефон, управление плеером, отсылка смс (но можно в консоли mconnectctl send-sms ), шаринг и т.п. пока не работают. Т.ч. это не замена.

Лучше всего установить SSHDroid (работает даже без рута), и копируй что хочешь хоть по WiFi, хоть по usb шнурку

А как при работе по шнурку локальная сеть поднимается? Это делается автоматически, или надо какие-то телодвижения предпринимать? Ну там IP выделить и др. Кто за это отвечает?

MTP — ублюдочная технология дурацкого мелкософта.

Вот ведь интересно — разработал мелкософт, а внедрил по факту гугль. Причём так хорошо внедрил, что традиционный (и гораздо более гибкий) USM большинство производителей андроидфонов просто выпилили.

традиционный (и гораздо более гибкий) USM большинство производителей андроидфонов просто выпилили.

без этого не получится сделать встроенную флешку, которую можно монтировать через сеть, не размонтируя rootfs на девайсе.

(другой вопрос, что лучше бы гугол придумал свой проприетарный велосипед, чем внедрять не менее проприетарный и говенный MTP)

Спасибо за наводку! Потыкаю.

Тот же вопрос, что и предыдущему оратору: IP-сеть при этом кем создаётся? IP ведь всё равно нужен, что для SSH, что для FTP. Я в тонкостях низкого уровня андроидоподключения к компу, к сожалению, слабо разобрался (а придётся).

Ведроидосмартфоны (с 4 версии ЕМНИП) все умеют поднимать WiFi-сеть или раздавать соединение по USB. В любом случае оба устройства будут в одной сети.

А как при работе по шнурку локальная сеть поднимается? Это делается автоматически, или надо какие-то телодвижения предпринимать? Ну там IP выделить и др. Кто за это отвечает?

В телефоне есть DHCP, поэтому все автоматически. Достаточно его воткнуть и выбрать режим модема в телефоне. Это если использовать DE. Если нет network manager, то надо dhcp сеть на интерфейсе телефона в ручную поднять.

SSHDroid при запуске высвечивает ip, к которому коннектиться с компа.

В случае с WiFi через общеквартирный роутер еще проще, ничего поднимать и не надо.

Вот ведь интересно — разработал мелкософт, а внедрил по факту гугль. Причём так хорошо внедрил, что традиционный (и гораздо более гибкий) USM большинство производителей андроидфонов просто выпилили.

Во времена 4 андроида какая-то особая повальная мода была на MTP онли. А сейчас, я смотрю, в современных, особенно не самсунгах, режим флешки есть обычно.

SSHDroid при запуске высвечивает ip, к которому коннектиться с компа.

Судя по всему, годнота, попробую.

Работает даже без рута, но тогда не на 22 порту, а на 2222 например. То есть при подключении тогда нужно указывать порт, потому что не дефолтный.

В X-plore есть режим wifi-сервера. У самсунга есть аж две утилиты для доступа к файлам smart switch (по шнурку) и side sync (по вайфаю и можно экран смарта шарить и уведомления принимать).

Источник

Оцените статью