Sunday 13 April 2014

Nexus 4 USB Connection Setup on Linux

Setting up USB transfer mode on my Nexus 4 was not as straightforward as I thought it would be. This post details how you can connect your Nexus 4 quickly to Linux Mint or Ubuntu. The solution involves using Go-mtpfs a simple FUSE filesystem for mounting Android devices as a MTP device.
  • Connect your Nexus 4 to your Linux box 
  • Under the 'Notification's window on the Nexus 4 it will show the USB options which you can select

 
  •  Ensure 'Media device (MTP)' is selected

  • Disconnect the Nexus 4 USB from the Linux box
  • From the terminal
$ sudo add-apt-repository ppa:webupd8team/unstable
$ sudo apt-get update
$ sudo apt-get install -y go-mtpfs
  • This will create a '/media/MyAndroid' directory
  • Connect your Nexus 4 vis USB
  • Create a simple mount bash script 'Nexus4MountUSB.sh'

  •  Create a simple dismount bash script 'Nexus4DisMountUSB.sh'
 

Some Useful Things

  • You can add the script under the a bin directory in your home folder i.e. mkdir ~/bin/
  • Add your bin directory (insert your username for <username>) to your PATH within ~/.bashrc Syntax

export PATH=/home/<username>/bin:$PATH

Example

export PATH=/home/cwishaw/bin:$PATH

  • Give the files executable privileges 
$ chmod +x Nexus4MountUSB.sh
$ chmod +x Nexus4DisMountUSB.sh
  • Using a fast access top down terminal like Guake is great to quickly start scripts with F12
  • FUSE (Filesystem in Userspace) allows non privilaged users to export a virtual filesystem to the Linux kernel
  • MTP (Media Transfer Protocol) is used from Ice Cream Sandwich to access the devices storage via USB
  • It allows access to the phone from the PC and the device simultaneously which the older USB Mass Storage did not  

No comments:

Post a Comment