Disable Device Automounting using Udisks

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"

2 comments to Disable Device Automounting using Udisks

  • Grateful

    Thanks. Very handy info. There’s just TOO MUCH automounting going on these days. Autofs does great with targeted things, just yank them when done, but other things don’t like that. Begone I say! It worked great for me modified for my instance.

  • Tobias

    One can also use

    sudo udisks –inhibit

    to avoid all automounting temporarily.
    Interrupt this process with Ctrl-c to stop the blocking of the usb devices.