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.

  • apt purge udisk\* Jun 4 '17 at 16:38

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
  • Thanks a lot, this did work indeed. I selected your comment as the answer. Have a good day!
    – Nerotix
    Jun 5 '17 at 14:54

We also recently has this issue - we wanted only authorized USB Drives to be used. This is how we accomplished it - Using Ubuntu 16.

Disable the /media folder

Disable non root user access to the media folder

chmod 400 /media

Make an Approved Mount Point

Provide an alternative mount point for approved USB Drives.

mkdir /approvedusb
mkdir /approvedusb/financepen
chmod -R 777 /approvedusb

Insert Approved USB Drive

We need to calculate the approved USB Drives blkid

su blkid 

Then write the UUID Code into the /etc/fstab

UUID=AEF0-9F26  /approvedusb/financepen  auto,user,rw,defaults,nobootwait      0 0

if its fuse mounts there are settings for gnome and mate desktop as such:

  gsettings set org.mate.media-handling automount false

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

Its also important to keep in mind that this is a per user setting. So it is valid only for the current desktop user....

check with:

gsettings list-recursively  org.mate.media-handling


gsettings list-recursively  org.gnome.desktop.media-handling 

Due to the mixed nature of the mate desktop (there are always some gnome apps I use) there seem to be some gnome settings leaking into the desktop configuration. So I always set both parts to make sure.....

  • Doesn't work for hot-plugged SATA drives.
    – Oskar Skog
    May 18 '20 at 8:10

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.