6

I'm trying to disable the automounting of any usb device. I have this working in Ubuntu 10.04, but I'm trying to do the same in either 12.04 or (ideally) 13.04 but not having any luck.

Everywhere I look tells me to run dconf-editor, then go to org,desktop,media-handling and untick automount and automount-open. This method worked in 10.04 but not in the others. I've also tried ticking autoopen-never with the other two unticked, but not had any luck.

I'm using VirtualBox VMs to do this in, I don't know if that will have a bearing on my result. I have set-up a blank USB device filter to catch all devices and attach them to the VM. Any suggestions welcomed!

Edit:

Thanks for all the suggestions. I started again with a clean install and managed to get this working, I think it must have been something to do with my VM settings, but I don't know what!

4

You could write a udev rule to disable automounting.

  • Create the file /etc/udev/rules.d/85-no-automount.rules
  • Copy this line into it SUBSYSTEM=="usb", ENV{UDISKS_AUTO}="0"
  • Reboot the system

This should prevent any USB device from being mounted by the udisksd daemon.

  • You don't need to reboot, you can do a service udev restart in order to update the udev's rules. BTW great trick, where do you found the info about the UDISKS_AUTO thing? – gipi Nov 9 '13 at 11:51
  • I did try simply restarting udev, but only rebooting did it for me. The feature is documented in the fine udisks manual : udisks.freedesktop.org/docs/latest/udisks.8.html – jcharaoui Nov 11 '13 at 15:37
  • Can this rule above prevent other udev rules to yet again automount the device? More clearly, does the rule prevent that udev carries out any other rules related to usb memory? – humanityANDpeace May 18 '14 at 8:54
  • No it doesn't, it simply instructs the udisk daemon not to automount the device. – jcharaoui May 21 '14 at 14:51
3

gsettings

I found this thread on askubuntu, titled: Disable automount notification for usb-drive. One of the answers says to run this command:

$ gsettings set org.gnome.desktop.media-handling automount-open false

It's unclear if this just disables the notification messages or also the automounting though.

blacklisting usb devices

You can also just blacklist the Kernel module responsible for USB storage, which has the effect of disabling the automounting:

$ sudo echo "blacklist usb-storage" >> /etc/modprobe.d/blacklist.conf

References

  • 1
    Thanks, I tried that earlier as I must have come across the same thread, and that doesn't do the trick either – James Jul 31 '13 at 14:52
  • @Kells1986 - what about the 2nd one? – slm Jul 31 '13 at 14:53
  • Just tried that too, it didn't work either, something strange is going on! – James Jul 31 '13 at 15:26
  • 1
    Came across this links as well: askubuntu.com/questions/301122/…. 3rd way of doing it. – slm Jul 31 '13 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.