# MTP (Русский)

Ссылки по теме

- USB накопители

MTP, or the Media Transfer Protocol, is a USB device class which is used by many mobile phones (e.g. Android 3+ devices) and media players (e.g. Creative Zen).

Эта страница нуждается в сопроводителе

Статья не гарантирует актуальность информации. Помогите русскоязычному сообществу поддержкой подобных страниц. См. Команда переводчиков ArchWiki

## Установка

Поддержка MTP осуществляется с помощью libmtp, для этого установите пакет libmtp из официальные репозитории.

Совет: После установки рекомендуется перезагрузить компьютер.

Чтобы просматривать содержимое накопителя вашего Android устройства через MTP в файловом менеджере, установите соответствующий плагин:

- Для файловых менеджеров, которые используют GVFS (GNOME Files, Xfce's Thunar), установите gvfs-mtp для поддержки MTP и gvfs-gphoto2 для поддержки PTP.
- Для файловых менеджеров, которые используют KIO (KDE's Dolphin), установите kio-mtp[ссылка недействительна: сохранено в aur-mirror] (поддержка PTP уже включена в него).

Также существует альтернатива плагинам: минималистичный MTP клиент android-file-transfer.

После установки необходимых пакетов, ваше устройство должно отобразиться в файловом менеджере автоматически, и вы сможете получать доступ к файлам по URL наподобие такого: `mtp://[usb:002,013]/`.

Примечание: Если у вас более новое Android устройство, которое не поддерживает UMS (USB-накопитель) и вы считаете что mtpfs очень медленный или работает некорректно, то вы можете установить jmtpfsAUR из AUR.

## Использование

Примечание: Не забудьте разблокировать ваш телефон (лок-скрин) перед подключением, потому что иначе вы увидите сообщения об ошибке.

After installation, you have several MTP tools available. Upon connecting your MTP device, you use:

    # mtp-detect

to see if your MTP device is detected. If you get errors about permission, remember that you need to be in the uucp group to access the USB system in general.

To connect to your MTP device, you use:

    # mtp-connect

If connection is successful, there are several switch options to use in conjunction with `mtp-connect` to access data on the device.

There are also several stand alone commands you can use to access your MTP device such as,

Warning: Some commands may be harmful to your MTP device!!!

     mtp-albumart        mtp-emptyfolders    mtp-getplaylist     mtp-reset           mtp-trexist
     mtp-albums          mtp-files           mtp-hotplug         mtp-sendfile
     mtp-connect         mtp-folders         mtp-newfolder       mtp-sendtr
     mtp-delfile         mtp-format          mtp-newplaylist     mtp-thumb
     mtp-detect          mtp-getfile         mtp-playlists       mtp-tracks

If you see a message like:

    Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.
    Please report this VID/PID and the device model to the libmtp development team

You should check whether your device has been already in this list: [Supported devices list[1]] If it is not, you should report it to the development team. If it already is, your libmtp might be slightly outdated. To allow it to be properly used by libmtp, you can add your device to:

    /usr/lib/udev/rules.d/69-libmtp.rules

## Using media players

You can also use your MTP device in music players such as Amarok. To do this you may have to edit `/usr/lib/udev/rules.d/51-android.rules` (the MTP device used in the following example is a Galaxy Nexus): To do this run:

    $ lsusb

and look for your device, it will be something like:

    Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]

in which case the entry would be:

    SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"

Then, reload udev rules:

    # udevadm control --reload

Note: After installing MTP you may have to reboot for your device to be recognised

## mtpfs

Warning: The following is likely to not work and you might have to resort to gphoto2 or a file manager with gvfs support like PCManFM.

Mtpfs is FUSE filesystem that supports reading and writing from any MTP device. Basically it allows you to mount your device as an external drive.

Mtpfs can be installed with the packge mtpfs, available from the official repositories.

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

    user_allow_other

- To mount your device

    $ mtpfs -o allow_other /media/YOURMOUNTPOINT

- To unmount your device

    $ fusermount -u /media/YOURMOUNTPOINT

- To unmount your device as root

    # umount /media/YOURMOUNTPOINT

Also, you can put them into your ~/.bashrc:

    alias android-connect="mtpfs -o allow_other /media/YOURMOUNTPOINT"
    alias android-disconnect="fusermount -u /media/YOURMOUNTPOINT"

Or, with sudo

    alias android-disconnect="sudo umount -u /media/YOURMOUNTPOINT"

Note: if you want not be asked for password when using sudo, please refer to USB storage devices

## jmtpfs

jmtpfs is a FUSE and libmtp based filesystem for accessing MTP (Media Transfer Protocol) devices. It was specifically designed for exchanging files between Linux systems and newer Android devices that support MTP but not USB Mass Storage. jmtpfs is available as jmtpfsAUR in the AUR.

Use this commands to mount your device:

    $ jmtpfs ~/mtp

And this command to unmount it:

    $ fusermount -u ~/mtp

## go-mtpfs

Note: Go-mtpfs gives a better performance while writing files to some devices than mtpfs/jmtpfs. Try it if you have slow speeds.
Note: Mounting with Go-mtpfs fails if external SD Card is present. If you have also external SD Card please remove it and then try mounting again.

If the above instructions do not show any positive results one should try go-mtpfs-gitAUR from the AUR. The following has been tested on a Samsung Galaxy Nexus GSM, Asus/Google Nexus 7 (2012 1st gen model), Samsung Galaxy S 3 mini and Google Nexus 4. (This is the only mtp software which worked for me on Nexus 4. Settings are usb debugging enabled, connected as media device.)

If you want do it simpler, install go, libmtp and git from the official repositories. After that install go-mtpfs-gitAUR from the AUR.

As in the section above install android-udev which will provide you with "/usr/lib/udev/rules.d/51-android.rules" edit it to apply to your idVendor and idProduct, which you can see after running mtp-detect. To the end of the line add with a comma OWNER="yourusername". Save the file.

- Add yourself to the "fuse" group:

    gpasswd -a [user] fuse

- If the group "fuse" does not exist create it with:

    groupadd fuse

Logout or reboot to apply these changes.

- To create a mount point called "Android" issue the following commands:

    mkdir Android

- To mount your phone use:

    go-mtpfs Android

- To unmount your phone:

    fusermount -u Android

You can create a .bashrc alias as in the example above for easier use.

## simple-mtpfs

This is another FUSE filesystem for MTP devices. You may find this to be more reliable than mtpfs. simple-mtpfsAUR is available in the AUR or can be built from source. Do not run the following commands as root.

To list MTP devices run

    $ simple-mtpfs --list-devices

To mount a MTP devices (in this example device 0) run

    $ simple-mtpfs /path/to/your/mount/point

To un mount run

    $ fusermount -u /path/to/your/mount/point

## gvfs-mtp troubleshooting

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

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:MTP (Русский)#)

If you have installed the gvfs-mtp package, and your device doesn't show up in the file manager, you might need to write a udev rule in order to auto-mount the device.

Plug your device and get the vendor-id and product-id,respectively:

    $ lsusb
    Bus 001 Device 007: ID 0421:0661 Nokia Mobile Phones Lumia 920
    (...)

The two numbers after ID are vendorId : productID

Then make a udev rule, e.g.

    # nano /usr/lib/udev/rules.d/51-android.rules

and type this rule:

    ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp",  MODE="660", ENV{ID_MTP_DEVICE}="1"

Reload the udev rules.

    # udevadm control --reload

And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [2]

## kio-mtp troubleshooting

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/apps/solid/actions/solid_mtp.desktop

Change the line

    Exec=kioclient exec mtp:udi=%i/

To

    Exec=dolphin "mtp:/"

Categories:

- Sound (Русский)
- Imaging (Русский)
- Storage (Русский)
- Mobile devices (Русский)
- Русский

Hidden categories:

- Pages with broken package links
- Pages or sections flagged with Template:Merge