Neither one nor Many

 
September 27 2016

UPDATE:

It still works, and the android.sh script is still needed for my Huawei P10 it seems, but I found a faster way to sync files. Better use adb-sync! Compared to the awefully slow performance of mtp it's very fast. Also in my case mtp chokes up when syncing lots of files, or very large files. Seems like the connection is very unstable. With adb-sync I haven't experienced any of this.

Example usage: mkdir test; adb-sync -R /storage/emulated/0 ./test/ to sync everything...


Sometimes--actually quite often --I have some weird issues with my Linux laptop. I could dedicate many blog posts to this kind of stuff like handling three screens, hacks for my touchpad and trackball mouse, weird boot issues with btrfs, etc. However this is also one is especially weird and I don't want to forget how I fixed it.

Mounting Samsung Galaxy Note 4 on Ubuntu...

Bluetooth would have been very nice, my device is recognized (hcitool scan), but I never got it working using obexfs -b etc.... However after some struggling I got MTP working.

The mtp-connect tool might give you the following error repeatedly:

trigen@zenbook:~> mtp-connect
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
LIBMTP ERROR: couldnt parse extension samsung.com/devicestatus:1

I can try that a 100 times, and it will continiously fail. So I decided to debug it with strace. With this I found out that it sometimes worked! Only when stracing it.. So I made the following script:

trigen@zenbook:~> cat android.sh 
while true; do
    sudo umount -f -l /android
    # somehow strace makes it slower, and it suddenly works...
    sudo strace -f -F -ttt -s 10000 -o /dev/null jmtpfs /android
    sleep 1
done

Execute it with bash android.sh and probably only after one or two failures, it will not throw the error.. and you are able to browse your phone via the /android path (in this case). Don't forget to accept the dialog on the Phone, and it will not work if the screen is turned off (consider something like RedEye Stay Awake).

A few caveats! (DO NOT rm stuff from it..)

I recommend you only use this to copy files from the device, and not manipulate it too much, as sometimes the connection does timeout for some weird reason. When that happens simply abort the android.sh script, try umount -f -l /android and unplug, then plug the device back in again.

This happened when the connection stopped after I did a rm -rf * in the /android/Phone/DCIM/Camera/ path, and the connection got lost, it got screwed up:

root@zenbook:/android/Phone/DCIM# ll
ls: cannot access Camera: Input/output error
total 0
drwxr-xr-x  4 root root 0 sep 24 20:27 ./
drwxr-xr-x 50 root root 0 feb 14  4450805 ../
??????????  ? ?    ?    ?            ? Camera
drwxr-xr-x  2 root root 0 jun 19 22:36 Facebook/

So delete stuff using the device itself, install some app like Solid Explorer. Above problem was also fixed by using Solid Explorer to remove the files in Camera (so even though the directory seems to be erroneous, it was caused by something weird with the files, I verified that by also trying to move all the files into another directory, and in that case it was the new directory that was causing the I/O error).

Linux/Unix Comments (0)


Leave a Reply

Comment may not be visible immediately, because I process everything manually.**

**) I plan to automate this.., but it's on my ToDo since for ever..


Author:
Ray Burgemeestre
february 23th, 1984

Topics:
C++, Linux, Webdev

Other interests:
Music, Art, Zen