Debian – How to stop auto mounting of devices in Ubuntu

automountingdebianfilesystemsUbuntu

I have an Ubuntu 16.04 LTS desktop system that I use to rescue disk drives (using dd or ddrescue). Whenever I plug in a disk drive it is automatically mounted and shown in the file manager.

I don't want this because I am afraid of the disk to be rescued is modified by the mounting process. It is me who decides if and when that disk is mounted, and not some OS function.

Surprisingly I could not find a setting to deactivate the auto-mount function. Some solutions suggest to enter the affected partitions in /etc/fstab and disable mounting there, however as each disk drives to be rescued may have different partitions this is not going to work in my case.

How to fully disable the auto mount feature of Ubuntu?

Best Answer

The core of the automount system is probably the udisks system. The daemon process should be udisksd and the systemd service might be udisks2.service (at least on my Debian 9; the name might vary on Ubuntu).

Once you stop that service (e.g. with systemctl stop udisks2.service) the GUI session should be unable to auto-mount anything.

To make sure any other service does not reactivate it, you could mask it: systemctl mask udisks2.service.

Related Question