■debian busterでAndroidのmtp接続をfuseマウントに変える。
$ lsb_release -d
Description: Debian GNU/Linux 10 (buster)
■デバイスの情報を探す。
$ ls -l /dev/libmtp-2-4
lrwxrwxrwx 1 root root 15 7月 20 01:23 /dev/libmtp-2-4 -> bus/usb/002/084
$ lsusb | awk '/MTP/'
Bus 002 Device 082: ID 0b05:7772 ASUSTek Computer, Inc. Zenfone GO (ZB500KL) (MTP mode)
$ sudo udevadm info -a -n /dev/libmtp-2-4 | sed -e 's/^ //g' | ./myscripts/lsec Android
looking at device '/devices/pci0000:00/0000:00:14.0/usb2/2-4':
KERNEL=="2-4"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{rx_lanes}=="1"
ATTR{devpath}=="4"
ATTR{bNumConfigurations}=="1"
ATTR{bNumInterfaces}==" 1"
ATTR{product}=="Android"
ATTR{bDeviceProtocol}=="00"
ATTR{version}==" 2.00"
ATTR{tx_lanes}=="1"
ATTR{quirks}=="0x0"
ATTR{urbnum}=="540"
ATTR{bConfigurationValue}=="1"
ATTR{bDeviceSubClass}=="00"
ATTR{idVendor}=="0b05"
ATTR{manufacturer}=="Android"
ATTR{devnum}=="84"
ATTR{authorized}=="1"
ATTR{bcdDevice}=="0318"
ATTR{idProduct}=="7772"
ATTR{bDeviceClass}=="00"
ATTR{busnum}=="2"
ATTR{speed}=="480"
ATTR{configuration}==""
ATTR{bMaxPower}=="500mA"
ATTR{bmAttributes}=="80"
ATTR{avoid_reset_quirk}=="0"
ATTR{ltm_capable}=="no"
ATTR{serial}=="J9AXGF02J463A2J"
ATTR{removable}=="removable"
ATTR{maxchild}=="0"
ATTR{bMaxPacketSize0}=="64"
■jmtpfsを探す。
$ apt-file search jmtpfs
jmtpfs: /usr/bin/jmtpfs
jmtpfs: /usr/share/doc/jmtpfs/README.gz
jmtpfs: /usr/share/doc/jmtpfs/changelog.Debian.amd64.gz
jmtpfs: /usr/share/doc/jmtpfs/changelog.Debian.gz
jmtpfs: /usr/share/doc/jmtpfs/copyright
jmtpfs: /usr/share/lintian/overrides/jmtpfs
jmtpfs: /usr/share/man/man1/jmtpfs.1.gz
$ apt-cache show jmtpfs | ./myscripts/lsec Description-en:
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.
■jmtpfsのインストール
「MtpErrorCantOpenDevice」は先にMTPマウントされているときに出る。
$ sudo apt-get install -y jmtpfs
$ sudo mkdir /media/android
$ sudo jmtpfs /media/android/
Device 0 (VID=0b05 and PID=7772) is a Asus MemoPad 7 (ME572CL).
error returned by libusb_claim_interface() = -6LIBMTP PANIC: Unable to initialize device
terminate called after throwing an instance of 'MtpErrorCantOpenDevice'
what(): Can't open device
中止
■MTPでマウントしたままなので、アンマウントして再実行。
これで直接mpv動画プレイヤに渡せる。
$ sudo jmtpfs /media/android/
Device 0 (VID=0b05 and PID=7772) is a Asus MemoPad 7 (ME572CL).
Android device detected, assigning default bug flags
$ sudo ls -l /media/android/SDカード
合計 0
drwxr-xr-x 5 root root 0 4月 22 20:33 Android
drwxr-xr-x 2 root root 0 5月 4 03:44 Camera
drwxr-xr-x 2 root root 0 4月 21 21:12 LINE
drwxr-xr-x 2 root root 0 5月 13 06:38 Movie
drwxr-xr-x 2 root root 0 4月 21 21:12 PDF
drwxr-xr-x 2 root root 0 4月 21 21:12 Twitter
$ sudo find /media/android/SDカード/movie -name "*.mp4" -exec mpv --volume 35 {} +
$ sudo fusermount -u /media/android
$ sudo ls -l /media/android/SDカード
ls: '/media/android/SDカード' にアクセスできません: そのようなファイルやディレクトリはありません
■デバイス認識ルールを参照。
正しく認識しているので修正の必要性は無いけど、「590f」を「7772」にするくらいかな。
$ sudo ls /lib/udev/rules.d/ | awk '/libmtp/'
69-libmtp.rules
$ awk '/ASUS/{print $0;getline;gsub(", ","&\n ",$0);print $0}' /lib/udev/rules.d/69-libmtp.rules
ATTR{idVendor}=="0b05",
ATTR{idProduct}=="590f",
SYMLINK+="libmtp-%k",
MODE="660",
GROUP="audio",
ENV{ID_MTP_DEVICE}="1",
ENV{ID_MEDIA_PLAYER}="1"
$ sudo cp /lib/udev/rules.d/69-libmtp.rules{,.org}
$ sudo sdiff -w 300 -s /lib/udev/rules.d/69-libmtp.rules{,.org} | awk '{gsub(" *<","",$0);gsub(", ","&\n ",$0);print $0}'
ATTR{idVendor}=="0b05",
ATTR{idProduct}=="7772",
SYMLINK+="libmtp-%k",
MODE="660",
GROUP="audio",
ENV{ID_MTP_DEVICE}="1",
ENV{ID_MEDIA_PLAYER}="1"