If you are running the standard Ubuntu desktop (GNOME) on an older computer equipped with a physical optical drive, you are likely familiar with its default behavior. The moment you insert a CD or DVD into the tray, Ubuntu automatically mounts the disc to the file system (usually under /media/yourusername/) and throws an icon directly onto your desktop or Dock.
While this is convenient for casual users, it can be problematic if you are writing a script to securely wipe discs, or if you simply prefer to mount devices manually using the terminal so you can specify read/write permissions and exact mount points.
You can configure the GNOME desktop environment to completely ignore inserted discs, allowing the hardware drive to spin up without the operating system automatically hooking into the file system.
How to Stop Automatic Mounting
You can disable the automount feature via the gsettings command in the terminal.
- Open your terminal application (
Ctrl+Alt+T). - To disable the automatic mounting of any inserted media (including CDs, DVDs, and USB drives), run the following command:
gsettings set org.gnome.desktop.media-handling automount false
- To stop Ubuntu from automatically popping open a file browser window when a disc is inserted, run this command as well:
gsettings set org.gnome.desktop.media-handling automount-open false
The changes take effect immediately. The next time you insert a CD or DVD into your optical drive, the system will recognize the hardware, but it will not automatically mount the partition. You will need to mount it manually using the mount command or by clicking on the drive in the “Other Locations” tab of your file manager.