[HOWTO] Mount Nexus 4 in Linux


Senior Member
Jun 29, 2011
Dallas, TX
You are unable to just plug in your Nexus 4 in Linux but it is very easy to mount and unmount to move data to/from your sdcard. This is one option that will allow you to utilize Nautilis (or any other file browser) to copy files to/from your Nexus 4. This is written for Ubuntu, but should work the same for other Linux systems. Also, this should work for Nexus 7 and 10.

1. Enable Developer options and enable USB debugging.
2. Install necessary modules to your computer:
sudo apt-get install mtp-tools mtpfs
3. Configure 51-android.rules:
sudo gedit /etc/udev/rules.d/51-android.rules
paste the following at the end of the file (if the file does not exist then just paste):
#LG - Nexus 4
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666"
#Samsung - Nexus 7 & 10
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"

Save and exit.
4. Make the file executable:
sudo chmod +x /etc/udev/rules.d/51-android.rules
5. Restart udev
sudo service udev restart
6. Create mount point and permissions (will need to do this for other Nexus' if using for the 7 or 10)
sudo mkdir /media/nexus4
chmod 755 /media/nexus4

7. Plug in the Nexus 4 and make sure MTP is enabled.

8. Mount with the following command:
sudo mtpfs -o allow_other /media/nexus4

9. When you have completed your work you must unmount:
sudo umount /media/nexus4

Now each time you need to copy from/to your Nexus 4 to your Linux computer you only need to plug in and run 8, then 9 when you have completed your work.


Senior Member
Aug 11, 2010
I prefer adb+qtadb. Better speed and stability compared to mtp i think. :)

Sent from my Blade using xda app-developers app

Yes QtADB works very nicely also. It requires a little more setup than gMTP, but you are correct that it is a little faster and stable.
Never heard of that. What is it?

Generating random authentication keys

---------- Post added at 07:48 AM ---------- Previous post was at 07:47 AM ----------

This isn't so much a Nexus 4 guide as a general Linux mounting guide, but still cool. Thanks!
Haven't gotten my N4 yet but I'm gonna try this on my sIII.

Generating random authentication keys


Senior Member
Nov 1, 2010
It seems that mtpfs 1.1 is broken. I downgraded to 1.0 and it worked. However, there is usually lag for some reason whenever the screen is off.


Senior Member
Apr 10, 2012
I had MTP/PTP crash several sdcards of mine which required me to format them (no write permissions had no way to get that back.)
Ever since that I just use ADB (Android Debugging Bridge) there are several GUI front-ends available in the default deb/rpm repositories, or if you are comfortable with the terminal (and with ADB it's really really simple to master) you can just get the binary and put it in your bin folder and transfer it via that. Highly reliable, speed is about 2-3mb/s -- but it works. :)


Senior Member
Aug 9, 2009
Union City California
I gave up on this on Debian Testing. My Galaxy Nexus would not mount no matter what udev rules I used and mtpfs is not a solution. Instead, I just use a ftp server on the phone and ftp things to it or push things using adb. I've also tried airdroid a few times. I would not mind trying the sshfs alternative either. Gonna check that one out.


Senior Member
Jul 19, 2012
OP's use of udev inspired me to come up with this solution using ADB.
I'll assume you have ADB installed. There's plenty of indepth guides for that elsewhere.

This tutorial will have you playing around in system directories on your Linux install. I tried to make this guide user friendly but you should have at least SOME knowledge of Unix like OSes before you even try this.
Not for the faint of heart.

Get http://https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid&hl=en from the play store. Enable USB debugging in the developer options on your phone.
Open SSHDroid on your phone and set your port to something other than 22. I use 2222.
Open a terminal window on your computer and elevate yourself to root (Preferably using su -. Otherwise use sudo su -.).
Now that we got that done, try logging into your phone to make sure everything works. It'll be something like
ssh -p2222 [email protected][yourPhone'sIP]
. If you get asked a password it probably works. Just hit ^C (Ctrl+C) to exit that password prompt since we don't need to go further yet.
Next you'll need to create a passwordless SSH login. Run
ssh-keygen -t rsa
. Just hit enter to use the defaults on all the questions, we don't need anything more.
Now run
scp -P2222 ~/.ssh/id_rsa.pub [email protected][yourPhone'sIP]:/emulated/storage/legacy/
. When it asks for the password just type "admin", though it should tell you that anyway.
If the file copied over successfully you should no be able to type
ssh -p2222 [email protected][yourPhone'sIP]
again and not be prompted with a password at all. Cool!
At this point it's recommended you go into the SSHDroid settings on your phone and untick the "Enable Password" box, though it's not required, especially if you want to ssh to your phone from other devices/computers.
Run lsusb and look for the line that says Google in it. You want to look out for something like
Bus 001 Device 070: ID 18d1:4ee2 Google Inc.
Copy the two alphanumeric codes before "Google Inc.". The first is your vendor ID and the second is your device ID. You might want to label them so you remember which is which.
Here's the scary part of the tutorial. Use your favorite text editor (preferably command line based) and create a new file at "/etc/udev/rules.d/85-android_mount.rules". Copy and paste this and edit to fit the IDs you got in the previous command.
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4ee2", RUN+="/usr/local/sbin/phone-mount -m" SYMLINK+="Nexus_4"
SUBSYSTEMS=="usb", ACTION=="remove", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4ee2", RUN+="/usr/local/sbin/phone-mount -u" SYMLINK+="Nexus_4"
It should be obvious where you need to put your Vendor and Device IDs now.
Save it and run these commands.
chmod +x /etc/udev/rules.d/85-android_mount.rules
chmod 775 /etc/udev/rules.d/85-android_mount.rules
chown root:root /etc/udev/rules.d/85-android_mount.rules
Now we need to create another file at "/usr/local/sbin/phone-mount" and paste this inside.
export PATH=/opt/android-sdk-update-manager/platform-tools/:$PATH

case "$1" in
    -m )
        adb wait-for-device
        adb forward tcp:2222 tcp:2222
        # If you have SSHDroid Pro you just need to add "pro" to the "sshdroid". 
        adb shell am broadcast -a berserker.android.apps.sshdroid.command.START
        sshfs -p2222 -o allow_other,idmap=user [email protected]:/storage/emulated/legacy/ /media/nexus4
        exit 0

     -u )
        umount /media/nexus4
        exit 0
We need to modify the permissions for this file too.
chmod +x /usr/local/sbin/phone-mount
chmod 775 /usr/local/sbin/phone-mount
chown root:root /usr/local/sbin/phone-mount
Almost done. If you don't already have sshfs installed on your Linux install then do so now. You'll also need to enable the "allow_other" option. For my distro it's as simple as editing "/etc/fuse.conf" and uncommenting the "user_allow_other" line. Your results may vary.
Now finally we need to create the actual folder you'll be mounting your Nexus 4 at. If you blindly followed my guide that'll be /media/nexus4.
mkdir /media/nexus4
chown root:users /media/nexus4
chmod 775 /media/nexus4
Now all we need to do is restart udev. Right now you'll want to make sure the phone is unplugged, then restart your udev daemon. For Debian based distros like Mint, Ubuntu, Debian, Crunchbang, etc. you'd run.
service udev restart
After it's done restarting you can plug your phone in, wait a few seconds, and hopefully have your phone automount to /media/nexus4 .

You may have to improvise in a few spots because all distros are not the same, especially when you compare something like Gentoo to Debian. If you're having problems with sshfs chances are your answer is on Google. You'll honestly get better help there than having me trying to guess your system.

Also note this is a pretty hacky and dirty way to do things. Don't go yanking your phone's USB cord out without unmounting "/media/nexus4" first. You shouldn't have any problems if you're not reading or writing anything, but there is the potential for data loss and crashing udev.
Last edited:


Senior Member
Jan 9, 2010
i got this error at the last step

Attempting to connect device
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
Android device detected, assigning default bug flags
Listing File Information on Device with name: (NULL)
fuse: bad mount point `/media/nexus4': Transport endpoint is not connected