View Full Version : Mounting Nexus 4 via MTP in Fedora 17

8th December 2012, 04:47 PM
Shiny new toy! I wrote a quick howto blog post for getting something working until a better solution comes along. :)

Link to blog edited out as per sub-forum rules --- DBelton


First, install libmtp and simple-mtpfs. There are other projects like mtpfs (http://code.google.com/p/mtpfs/) (seems unmaintained) and go-mtpfs (https://github.com/hanwen/go-mtpfs) (uses some oddball compiler) so I stuck with simple-mtpfs (https://github.com/phatina/simple-mtpfs) because it’s already in the Fedora repos and seems to work.

$ sudo yum -y install fuse fuse-libs libmtp simple-mtpfs

NOTE: you probably already have fuse/fuse-libs and gvfs-fuse installed. Googling around I see there’s work on a MTP interface to GVFS (http://intr.overt.org/blog/?p=153) but it’s not ready yet.

Next, write some quick udev rules to see your Nexus 4 — as of this writing (libmtp-1.1.5-1.fc17) they’re not in the stock /usr/lib/udev/rules.d/69-libmtp.rules file. I’m sure this will get updated, so we’ll put them in our own file and not edit the stock one. Create /etc/udev/rules.d/99-nexus4.rules with:

ACTION!="add", GOTO="nexus4_rules_end"
ENV{MAJOR}!="?*", GOTO="nexus4_rules_end"
SUBSYSTEM=="usb", GOTO="nexus4_usb_rules"


# LGE Nexus 4/10 MTP
ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee1", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

# LGE Nexus 4/10 MTP+ADB
ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"


Last, make your life a bit easier and add two aliases to mount/unmount your device. Make a directory (I used ~/Misc/Nexus4) and add something like the below to your ~/.bashrc file:

alias n4mount="simple-mtpfs ~/Misc/Nexus4"
alias n4umount="fusermount -u ~/Misc/Nexus4"

At this point you can either reboot (admit it, you needed to apply that new kernel update anyways) or reload your udev rules and log out/log in:

$ sudo udevadm control --reload-rules

You’re ready to rock & roll – I seem to be having a spurious problem where the first time I run the mounting alias it “doesn’t work” but the second time I run it it works fine, so “n4mount;n4umount;n4mount” and then my device shows up. Your mileage may vary here – when you plug in your Nexus 4 there should be a new device symlink being created that something like:

$ ls -l /dev/libmtp*
lrwxrwxrwx 1 root root 15 Dec 8 08:41 libmtp-2-1.1 -> bus/usb/002/007

If you’re not seeing that after plugging in your device, something’s not right – go back and check your rules and such again. Using the above I’ve been able to copy over all my backups, MP3s, etc. to the device seemingly without any errors or causing any device harm.

8th December 2012, 07:48 PM
As per the sub-forum rules, there are no links to blogs allowed in guides posted in here.

Since your post pretty much has all of the information contained in the blog post, I simply removed the link in your post above. Please look over your post above and make sure that it does indeed contain everything needed, though.

This is a nice guide, and thanks for posting it here. There have been several people interested in using a nexus with their Fedora machine.

8th December 2012, 07:58 PM
ahh, gotcha - I visit all of a few times a year and maybe post some Howto and nobody has brought this up before, didn't know about the link rule. Yes, I on purpose replicated the content here to protect against disappearing links. :) I get a bunch of referrals from this forum for my "Installing Fonts" (2010) and "Disable Pulseaudio" (2009) Howtos in this forum...

8th December 2012, 08:40 PM
I was looking around on your blog and it has some pretty useful information on it.

It is just in this sub-forum (Guides & Soultions) that has the no link to blogs rule in it, and one of the main reasons is the one you stated above. If you have been copying all of the information over anyway, that's probably why it's never been noticed or anyone said anything about it.

Anyone interested in checking out the blog, the link is in his signature :)

12th January 2013, 05:51 AM
Thanks for this guide. I used it to access my HTC One X which since the update to Jelly bean is using MTP.

Only extra step apart from using the correct Vendor and Product ids (0bb4 & 0dfb) was that I found the device had to be unlocked for it to mount correctly. It still shows the device as unknown but I can access the data.

12th January 2013, 06:04 AM
My own experience, with the Galaxy SIII has been a bit easier. Just installed simple-mtpfs and was then able to mount it with simple-mtpfs /mnt

Note that I was doing it for short periods, mostly to transfer a few pdfs from work (I converted them to epub and used the Nook app), and some silly sound bites for ring tones.

I have not found the unlocked locked thing to be consistent--that is, sometimes it doesn't work when locked, other times it has.

I didn't have to make udev rules. I've also found, on ArchLinx, that jmtpfs also works quite well.

12th January 2013, 03:02 PM
The Samsung Galaxy models have their vendor/product IDs listed in /lib/udev/rules.d/69-libmtp.rules with the shipping version if libmtp, which is why you're having a smoother time. I'd hazard a guess that they are the same for S2/S3 so have been around for awhile? Eventually a new version of libmtp will ship that has an updated udev ruleset for the N4, HTC One series, etc.

12th January 2013, 05:17 PM
Interesting--thank you for the explanation, which I suspect will help others in the future.

Jon Baron
12th January 2013, 06:00 PM
I was able to mount a Nexus 10 through the usb connector. Just plug it and say
simple-mtpfs mountpoint
You need to install simple-mtpfs from the rpm of that name, and mountpoint
should be an empty directory. At the end, as usual, say
fusermount -u mountpoint.

I got an error message, but I ignored it. This works as it should. I can then copy files into the Download directory, and access them with the Astro file manager app.

This might be useful for other Android devices, so I am commenting here, even though this is about Nexus 4, not 10.

13th January 2013, 01:09 AM
The HTC One X has been added to the latest version according to http://sourceforge.net/p/libmtp/bugs/663/ I guess others have too and we'll see it as an update a some stage.

23rd January 2013, 03:41 AM
I have a Sony Xperia Tipo running CyanogenMod 10 (Android 4.1.2). simple-mtpfs does mount the device, but I can't get any data to move. Any and all disk operations just hang for a long while and then do nothing. I have


at the Fedora end of the cable.

23rd January 2013, 04:56 AM
One thing that I'm finding pretty consistently is that the phone should be unlocked at time of connection. Other than that, no real help, I'm afraid. You might try the jmptfs, but of course, it might turn out to be a complete waste of your time.

24th January 2013, 02:01 AM
I needed to put some MP3s on my phone and ended up trying all kinds of things. I don't have a home wireless network up, temporarily also don't have access to my Dropbox, Google Drive was taking indefinitely to sync anything, etc. etc. Eventually I zipped the files and pushed them onto the phone over Bluetooth. Took forever for 55 MB, but they got there. Then it turns out that clicking on the zip file in my file manager on Android doesn't do anything. No unzip, apparently. CyanogenMod comes with a terminal emulator installed by default. Turns out command-line unzip is there and worked on my zip archive as advertised. I was actually a bit pleased with myself.

26th January 2013, 03:25 PM
Small update - I updated the original post to add MTP+ADB idProduct and list the comments as 4/10 compatible. I was browsing the libmtp source and see that on 2012-12-26 they added these into the source, so in theory the next packaged release will obsolete the need for adding custom udev rules.

I still get janky problems trying to rsync data off sometimes - like this morning I get:

$ bkpn4.sh
sending incremental file list
file has vanished: "/home/tengel/Misc/Nexus4/TunnyBrowser/cache/speeddial_covers/00cdf31b.cache"
file has vanished: "/home/tengel/Misc/Nexus4/TunnyBrowser/cache/speeddial_covers/30d27251.cache"
file has vanished: "/home/tengel/Misc/Nexus4/TunnyBrowser/cache/speeddial_covers/68a98b16.cache"
file has vanished: "/home/tengel/Misc/Nexus4/TunnyBrowser/cache/speeddial_covers/8d080e2e.cache"
file has vanished: "/home/tengel/Misc/Nexus4/TunnyBrowser/cache/speeddial_covers/a12f52c5.cache"
rsync warning: some files vanished before they could be transferred (code 24) at main.c(1052) [sender=3.0.9]

It's seemingly random where I get these "file has vanished" errors - sometimes on pictures, sometimes on cache files. If I remount the device a few times or reboot it they might start working. One time these errors led to *something* going wrong on the device and a picture disappeared from my DCIM/Camera folder - *poof* gone. I use FolderSync and my free 50GB box.net to try and keep backups because of these results.

I do not yet trust mtpfs in Linux, I think it's very unstable - I seriously lament the loss of USB Mass Storage, it's a real kick in the pants to have to deal with this crappy MTP support.

27th January 2013, 06:28 PM
gnomad2 appears to work with my CM10 (Android 4.1.2) phone well enough. It has a graphical UI for transferring files. I can't actually tell if it mounts the phone in some way that can be accessed from the command line.