Setup
First up, install the necessary tools with sudo apt-get install mtp-tools mtpfs
Connect your Galaxy Nexus to your computer. On your phone, open up
the notification drawer, and click on "USB Connection type". Make sure
that MTP is selected.
Then, run these commands:
mtp-detect | grep idVendor
mtp-detect | grep idProduct
You shall get an output like this:
Now, run these commands:
gksu gedit /etc/udev/rules.d/51-android.rules
A Gedit window should open up. Type this text in it, all in a single line:
SUBSYSTEM=="usb", ATTR{idVendor}=="VENDORID", ATTR{idProduct}=="PRODUCTID", MODE="0666"
Replace VENDORID
with the idVendor
you had noted down earlier. Similarly, replace PRODUCTID
with the idProduct
you had noted down. In my case, they were 04e8
and 685c
respectively, but they might have been different for you.
Save and close the file. Then, disconnect your phone and run these commands:
sudo service udev restart
sudo mkdir /media/GalaxyNexus
sudo chmod a+rwx /media/GalaxyNexus
sudo adduser $USER fuse
$USER
is a default shell variable and should be the user you want to add (usually yourself). Now, run this command:
gksu gedit /etc/fuse.conf
In the Gedit window, remove the #
at the beginning of the last line (the one that begins with #user_allow_other
) like this:
You're almost done! Now, restart your computer, and then run these three commands:
echo "alias android-connect=\"mtpfs -o allow_other /media/GalaxyNexus\"" >> ~/.bashrc
echo "alias android-disconnect=\"fusermount -u /media/GalaxyNexus\"" >> ~/.bashrc
source ~/.bashrc