7

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!

2 Answers 2

5

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.

5
  • 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
    Commented Nov 9, 2013 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
    Commented Nov 11, 2013 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? Commented May 18, 2014 at 8:54
  • No it doesn't, it simply instructs the udisk daemon not to automount the device.
    – jcharaoui
    Commented May 21, 2014 at 14:51
  • sudo -i /bin/bash -c "echo 'SUBSYSTEM=="usb", ENV{UDISKS_AUTO}="0"' > /etc/udev/rules.d/85-no-automount.rules; service udev restart; cat /etc/udev/rules.d/85-no-automount.rules" (dont know why regular sudo doenst work)
    – alchemy
    Commented Apr 30, 2020 at 0:17
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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .