When running sudo apt update, sudo apt-get upgrade, or attempting to install software on Ubuntu, encountering the error message W: Failed to fetch cdrom://Ubuntu... Please use apt-cdrom to make this CD-ROM recognized by APT accompanied by the interactive terminal prompt Media change: please insert the disc labeled 'Ubuntu...' into the drive '/media/cdrom/' and press [Enter] halts the package manager completely. This error occurs because the Ubuntu installer automatically adds the installation media (USB flash drive or DVD ISO image) as the primary software repository in /etc/apt/sources.list. Once the installation drive is removed, APT repeatedly searches for the physical disc rather than pulling packages over the internet. Resolving this issue involves disabling the cdrom: repository line in your APT configuration files.
Why APT Searches for a Physical CD-ROM
The Advanced Package Tool (APT) consults repository lists in /etc/apt/sources.list and /etc/apt/sources.list.d/ to determine where to retrieve software packages. During standard offline installations, the installer writes a line beginning with deb cdrom:[Ubuntu...]/ at the very top of the repository configuration to permit package installation without internet connectivity. If this entry is not automatically removed upon system installation, APT prioritises the physical media entry on every update command. Because the USB drive or optical disc is no longer mounted at /media/cdrom/, APT aborts with a fetch error.
Common failure symptoms associated with the cdrom: repository entry include:
- Terminal Update Prompts: APT halting with the message “Media change: please insert the disc labeled…” and waiting indefinitely for user input. For locale errors, see our guide on fixing Failed to Set Locale in Ubuntu.
- Broken Software Center Installs: Ubuntu Software / App Center failing to install or update graphical applications. For cron stalls, see our guide on fixing cron jobs not running in Ubuntu.
- Repository Indexing Errors: Warning lines reading
E: The repository 'cdrom://Ubuntu... Release' does not have a Release file.. For GPG key errors, check our guide on fixing GPG error NO_PUBKEY in Ubuntu.
| Configuration File | Problematic Entry | Corrected Functional Entry |
|---|---|---|
/etc/apt/sources.list (Legacy format) |
deb cdrom:[Ubuntu 22.04 LTS...]/ jammy main |
# deb cdrom:[Ubuntu 22.04 LTS...]/ jammy main (Commented out) |
/etc/apt/sources.list.d/ubuntu.sources (deb822 format) |
URIs: cdrom:[Ubuntu 24.04 LTS...]/ |
Remove cdrom: URI entry or delete definition file |
| Software & Updates GUI | “Installable from CD-ROM/DVD” ticked | Unticked in Ubuntu Software tab |
Method 1: Comment Out the cdrom Line via Terminal (sources.list)
The fastest and most reliable method to resolve this error on modern and older Ubuntu systems is commenting out the cdrom: instruction in the main APT repository file.
- Open your terminal by pressing Ctrl + Alt + T.
- Open the master repository list in the nano text editor with administrative privileges:
sudo nano /etc/apt/sources.list - Locate any lines at the top of the file that begin with
deb cdrom:.
(Example:deb cdrom:[Ubuntu 22.04.1 LTS _Jammy Jellyfish_ - Release amd64]/ jammy main restricted). - Add a hash symbol (
#) and a space to the very beginning of eachdeb cdrom:line to convert it into an inactive comment:# deb cdrom:[Ubuntu 22.04.1 LTS...]/ jammy main restricted - Press Ctrl + O and hit Enter to save the file.
- Press Ctrl + X to exit the nano editor.
- Update your package lists to verify the fix:
sudo apt update
Method 2: Fix deb822 Format Repository Files (Ubuntu 24.04 LTS and Newer)
Ubuntu 24.04 LTS introduces the deb822 declarative repository format stored in /etc/apt/sources.list.d/ubuntu.sources rather than the classic sources.list file.
- Check if the
ubuntu.sourcesfile exists:ls -l /etc/apt/sources.list.d/ubuntu.sources - If present, open the file in nano:
sudo nano /etc/apt/sources.list.d/ubuntu.sources - Look for any stanza containing
URIs: cdrom:. - Delete that specific stanza or change the line to point exclusively to official HTTP mirrors:
URIs: http://archive.ubuntu.com/ubuntu/ - Save and exit (Ctrl + O, then Ctrl + X), then run
sudo apt update.
Method 3: Disable CD-ROM Media via the Software & Updates GUI
If you prefer using graphical tools, Ubuntu’s Software & Updates utility allows you to disable physical media sources with a single click.
- Press the Super key (Windows key) on your keyboard to open the Application launcher.
- Type Software & Updates and press Enter.
- In the Ubuntu Software tab, look at the bottom section.
- Locate the checkbox labelled Installable from CD-ROM/DVD (or Cdrom with Ubuntu…).
- Untick the checkbox.
- Click Close in the bottom-right corner. A prompt will state: “The information about available software is out-of-date.” Click Reload.
Method 4: Automate the Fix via sed One-Liner
For headless server installations or rapid automated provisioning, use sed to comment out all cdrom lines instantly without manual text editing.
- Execute the following inline stream editor command:
sudo sed -i '/^deb cdrom:/s/^/# /' /etc/apt/sources.list - This command searches for any line beginning with
deb cdrom:and prefixes it with#. - Execute
sudo apt updateto confirm smooth package synchronization over the network.
Method 5: Restore Clean Default Official Repositories
If your sources.list file was heavily altered or contains multiple corrupted repository directives, generating a clean baseline file restores official network repositories.
- Create a backup of your existing repository configuration:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - Write a fresh, clean official repository manifest for your Ubuntu release:
sudo sh -c 'echo "deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse" > /etc/apt/sources.list'sudo sh -c 'echo "deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse" >> /etc/apt/sources.list'sudo sh -c 'echo "deb http://security.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse" >> /etc/apt/sources.list' - Run
sudo apt update && sudo apt upgrade. Your system will now retrieve all packages smoothly from official Ubuntu mirrors.