cheatsheet.zwischenspeicher.info

Some tech documentation and snippets, finally organized.
Posts tagged as android

Mount an USB connected Android based smartphone into Linux

​User-mountable and world-readable, using fuse and jmtpfs:

Install required software:

$ apt-get install fuse jmtpfs usbutils

Connect the smartphone with an USB data cable and read out required information:

$ lsusb

The command returns a list of all connected USB devices; the line for my Moto G4 play looks like this:

Bus 001 Device 003: ID 22b8:2e82 Motorola PCS

Now use the printed Vendor and Product ID (before resp. after the colon) to create the according udev rule:

$ echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="2e82", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"' >> /etc/udev/rules.d/55-android.rules

Create mountpoint, make sure that you are in the audio group and test setup:

$ mkdir /media/motomobil
$ chmod a+rwx /media/motomobil/
$ jmtpfs -o allow_other /media/motomobil/
$ fusermount -u /media/motomobil/

jmtpfs will grab the first available device. Allternatively, the device can be specified with the -device=<busLocation>,<devNum> switch, to dump the parameters, run jmtpfs --listDevices.

Add fstab entry:

$ echo "jmtpfs       /media/motomobil       fuse       noauto,nodev,allow_others,rw,user,noatime       0       0" >> /etc/fstab