Ubuntu – Disable auto-mounting in Ubuntu 16.04

automountingd-busmountUbuntu

I'm working on creating an Ubuntu variant that has a lot of forensic analysis tools etc installed. However I can't seem to find out how to disable auto-mounting at all..I want it to NEVER mount anything, I always want to mount something manually.

I've done some searching and found this: How can I use gsettings to disable device automount in Ubuntu 16.04?

However, if I use: gsettings set org.gnome.desktop.media-handling automount false

It still auto-mounts. Also the thread says something about

The reason it failed on this occasion seemed to be caused by the lack
of environment variables being set, notably $DBUS_SESSION_BUS_ADDRESS.

Now I have now idea what this last part mean, anyone care to explain or have any other solution to fully disable auto-mounting cd/usb/sata etc.

Best Answer

One way of doing that is to write an udev rule that makes udisks2 ignore any added block devices. This can be done by dropping a file 10-myudisks2.rules in /etc/udev/rules.d with the rule:

ACTION=="add|change", SUBSYSTEM=="block", ENV{UDISKS_IGNORE}="1"

This is documented in:

man 7 udev
man 8 udisks
Related Question