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?

  • 3
    Good question, but I don't think it belongs on Server Fault. Would be a better fit for Ask Ubuntu or Unix & Linux. I have voted to migrate the question.
    – kasperd
    Dec 11, 2016 at 19:24
  • 1
    I'd suggest you gogle for linux forensic distribution there are better choices for your task. For ubuntu a search for dsiable automount gets you some hits.
    – LotPings
    Dec 11, 2016 at 22:44
  • 1
    You rather don't want Ubuntu for that at all, see forensicswiki.org/wiki/Forensic_Live_CD_issues -- a proper forensic rescue disk doesn't try mounting filesystems without taking extra care when looking for its squashfs, for example... the two proper implementations in this regard I know are grml.org and en.altlinux.org/rescue Dec 18, 2019 at 16:34

4 Answers 4


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.

  • 1
    sudo systemctl stop udisks2.service correctly disabled automount for my session in a 64-bit XUbuntu Linux version 16.04 (a.k.a. "Xenial Xerus"). Nov 3, 2019 at 3:16
  • 2
    Stopping udisk2.service not only disables automount, but also has possibly unwanted side effects. I.E. gnome-disks stops working, too.
    – Tino
    Mar 16, 2023 at 2:20

To stop auto-mounting of specific devices, add an entry to /etc/fstab with the noauto optiion.

Example entry (after getting the UID using the blkid command):

UUID=2017-09-15-16-48-31-00 none mac noauto 0 0

  • note, you may need sudo blkid to view all disks
    – Simon
    Mar 12 at 9:58

In Ubuntu 22.04 I was able to stop automatic mounting of devices using the dconf Editor. First install it:

sudo apt install dconf-editor

Next, run it and navigate up to this setting:

enter image description here

and simply disable it. That's it.

Source: here.

  • 5
    To automate: gsettings set org.gnome.desktop.media-handling automount false [source]
    – Tino
    Mar 16, 2023 at 2:28
  • Yeah, the GUI option is nice, but if you're willing to run a command-line program anyway (sudo apt install ...), you might as well run a gsettings command instead.
    – mwfearnley
    Jul 18, 2023 at 7:58

So you want to recover disks without messing with their contents. Yes, mounting their filesystems will increment counters, and possibly damage an already damaged filesystem.

In this case you can't just run dd on a disk to prevent this from happening, because by the time you plug it in that system has already automatically mounted it. You will be using the new udisks system to auto-mount new volumes based on udev events. You can turn this functionality off entirely in your GUI.

Within "Settings" > "Removable Drives and Media": uncheck all of the "removable storage" boxes. This should disable the feature entirely.

  • 1
    I can't find the "Settings" > "Removable Drives and Media" dialog you are mentioning. My Ubuntu system has a "System Settings" dialog but that page does not have a "Removable Drives and Media" dialog. I found a "Details" program having a "Removable Media" dialog but the "removable storage" check boxes do not exist.
    – nn4l
    Dec 11, 2016 at 19:05
  • 1
    Running sudo systemctl stop udisks2.service in the shell prior to connecting the defective device solves it in a Ubuntu system (I'm using the 64-bit XUbuntu 16.04 distro). The command dd should not be used for copying the contents of a defective drive: ddrescue should be used instead. Example: ddrescue -Adf -r 3 -v /dev/sdb1 sdb1.iso will attempt to copy partition 1 of disk sdb to a file sdb1.iso placed in the directory where such command is run. Running photorec sdb1.iso will cause photorec to read and copy the contents of sdb1.iso to the directory where such command is run. Nov 3, 2019 at 3:22

You must log in to answer this question.