How to Stop Ubuntu from Automatically Mounting Removable Drives

The Aggressive Automount

Ubuntu utilizes the GNOME desktop environment, which includes a highly aggressive file management system (Nautilus). By default, whenever you physically plug in a USB flash drive, an external hard drive, or insert an SD card, Ubuntu immediately detects the hardware, automatically mounts the filesystem, and often instantly opens a new Nautilus window displaying the drive’s contents. While this “plug and play” behavior is designed for convenience, it can be a massive security risk if you are inserting untrusted drives. Furthermore, if you are working on the command line and intentionally want to mount a drive manually to a specific directory (like `/mnt/backup`), the system’s automatic intervention creates a race condition that disrupts your workflow.

Restoring Manual Control

To prioritize security and stop Ubuntu from automatically mounting removable drives and opening file manager windows, you must change the media handling preferences within the system settings.

Click the system menu in the top-right corner of your screen (where the battery or network icons are) and click the gear icon to open the Settings app. In the left-hand navigation sidebar, scroll down and click on Removable Media (in some Ubuntu versions, this might be located under a broader “Default Applications” or “Details” menu). You will see options for how the system handles different media types (CDs, DVDs, Music Players). Look for the master checkbox at the very top labelled Never prompt or start programs on media insertion. Click this checkbox to enable it. This prevents the auto-execution. However, to stop the underlying auto-mounting completely, you must open your terminal and type: gsettings set org.gnome.desktop.media-handling automount false and press Enter. From now on, when you plug in a USB drive, nothing will happen until you manually open the file manager and explicitly click on the drive to mount it.

Get the best tech tips delivered straight to your inbox.

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