The Immediate Access
In modern Ubuntu desktop environments (like GNOME), the system is configured for maximum convenience. The moment you plug in a USB flash drive or an external hard drive, Ubuntu automatically detects the hardware, mounts the filesystem to a specific directory (usually under `/media/`), and often opens a file manager window displaying the contents. While this mirrors the behavior of Windows and macOS, it can be undesirable on a Linux machine. If you are inserting a potentially infected drive to scan it for viruses, or if you plan to immediately format the drive using the terminal, you do not want the operating system automatically mounting it and accessing the data first.
Preventing the Automount
To assert manual control over your hardware and stop Ubuntu from automatically mounting external drives upon insertion, you must modify the desktop environment’s specific media handling settings.
You can change this behavior using the hidden `gsettings` configuration database via the terminal. Open your terminal (Ctrl+Alt+T) and type the following command to disable automatic mounting: gsettings set org.gnome.desktop.media-handling automount false and press Enter. Next, to stop the file manager from automatically opening if you do decide to manually mount a drive, type: gsettings set org.gnome.desktop.media-handling automount-open false and press Enter. Both commands execute silently. From now on, when you insert a USB drive, nothing will happen visually. You will need to manually open your “Disks” utility or use the mount command in the terminal to access the data on the drive.