Linux: Disable usb automounting
Udisks and udev are related. Normally, as you can see from the above examples, when a new USB stick or DVD inserted, it is automatically mounted and the file manager is displayed. Suppose, instead, that you want that USB stick or DVD to be ignored and not mounted. How would you configure your system to do this?
While researching how to disable the automatic mounting of devices for a Linux kiosk project I was working on, I spent a number of hours on the Internet reading purported solutions to the problem. The majority of the solutions (probably 99%) simply did not work because the solution referred to obsolete versions of udev, HAL (Hardware Abstraction Layer), DBus or solutions based on PolicyKit or gsettings.
The simplest method that I have found is to create a low numbered file (I call mine 10-local.rules in /etc/udev/rules.d containing the following rule:
ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="sd*|sr", ENV{UDISKS_PRESENTATION_HIDE}="1"
A twist on the above rule would apply to a kiosk-like LiveCD containing a persistent data partition to restrict mounting to /dev/sda*:
ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="sd[b-e]*|sr", ENV{UDISKS_PRESENTATION_HIDE}="1" By: Zurlinux