How to Stop Ubuntu Linux from Automatically Mounting External USB Drives

The Auto-Mounting Behaviour

When you plug a USB flash drive or an external hard drive into a computer running the standard Ubuntu desktop environment (GNOME), the operating system immediately detects the hardware, mounts the filesystem, and often pops open a file manager window displaying the drive’s contents. While this “plug and play” convenience is expected by most desktop users, it can be problematic for system administrators, security-conscious users, or anyone performing low-level disk operations (like formatting or flashing an ISO image) who require the drive to remain unmounted upon insertion.

How to Disable Auto-Mounting via dconf-editor

To stop Ubuntu from automatically engaging with external storage, you need to modify the hidden GNOME media handling settings using a tool called dconf-editor.

1. First, open your terminal (Ctrl+Alt+T) and install the configuration editor by typing: sudo apt install dconf-editor

2. Once installed, launch the tool by typing dconf-editor into the terminal or finding it in your application menu.

3. A warning screen will appear advising you to be careful. Click I’ll be careful.

4. Navigate through the folder tree by clicking the following path: org > gnome > desktop > media-handling.

5. In the right-hand pane, look for the setting named automount.

6. Click on automount. Turn off the Use default value toggle switch, and change the Custom value to False.

7. For maximum security, you should also disable the automount-open setting in the same directory by changing its custom value to False as well.

Mounting Drives Manually

Once these settings are applied, your system will completely ignore newly inserted USB drives. The hardware will be detected by the kernel (which you can verify by typing lsblk in the terminal), but the filesystem will not be mounted or accessible until you manually mount it via the command line or by explicitly clicking on the drive icon in your file manager’s sidebar.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.