Saturday, December 29, 2012

Mount an Android to Linux with a USB cable

I want to be able to mount the Android as a USB drive, then do synchronization.

At present I use AirDroid to transfer files over WiFi (it seems not to work when the USB connection is in place, and of course if I move and am on another WiFi network I have to reset my WiFI settings) but it does not mount the device, just transfers stuff, so I haven't figured out how to use any scripts to automate any sort of synchronization.

The problem arises because the Androids do not function as USB block devices.

The link
    http://www.omgubuntu.co.uk/2011/12/how-to-connect-your-android-ice-cream-sandwich-phone-to-ubuntu-for-file-access
explains this and goes through the steps to connect.

But they don't work for me with a Samsung Galaxy Nexus on ICS under openSUSE 12.2. I can mount the phone and enumerate the directories, but the files do not appear.

So after much research, experimentation, and failure, I found a solution:

http://forums.opensuse.org/english/get-technical-help-here/hardware/478602-cannot-connect-samsung-galaxy-s3-android-4-via-usb-cable-4.html

Just install jmtpfs from the cited source (below). It just works:

1. As root:

    a. Create a mount point (a directory) in the /mnt directory. (Do not use /media as a base directory. Linux always deletes any directories in /media once they have been unmounted.)

    b. Change the mount point owner to user:users and permissions to 0777, e.g.:
        chown andy:users /mnt/nexus
        chmod 0777 /mnt/nexus


    c. Download and install jmtpfs from http://software.opensuse.org/package/jmtpfs?search_term=jmtpfs.

You do not need mtpfs or any of its contortions.

2. Plug in the Android, and let it settle out. dmesg says:

    [ 3760.517863] usb 1-1.1: new high-speed USB device number 5 using ehci_hcd
    [ 3760.605130] usb 1-1.1: New USB device found, idVendor=04e8, idProduct=685c
    [ 3760.605135] usb 1-1.1: New USB device strings: Mfr=2, Product=3, SerialNumber=4
    [ 3760.605139] usb 1-1.1: Product: Galaxy
    [ 3760.605141] usb 1-1.1: Manufacturer: samsung
    [ 3760.605144] usb 1-1.1: SerialNumber: 01498FE71000900F


or something similar.

3. As user (e.g., andy):

    a. Mount the device

        jmtpfs /mnt/nexus   

    b. View, copy, move, or delete files in either dolphin or konqueror.

    c. Enjoy.

Easy when you know how.

No comments: