Fix "Media change: please insert the disc labeled Debian GNU/Linux" (remove the CD-ROM from apt sources)

apt asks you to insert the Debian DVD because the installer left a "deb cdrom:" line in your sources. Comment it out, add the online Debian mirror, and run apt update. Steps for Debian 13, 12 and older, including the new .sources format.

Share
Debian apt error Media change: please insert the disc labeled Debian GNU/Linux

Media change: please insert the disc labeled 'Debian GNU/Linux ...' in the drive '/media/cdrom/' and press [Enter] means your apt sources still point to the DVD or USB stick you installed Debian from. The installer adds a deb cdrom: line when you install without a network mirror. Comment that line out, make sure the online Debian mirror is listed, and run sudo apt update.

Quick fix on any Debian version:

sudo sed -i '/^deb cdrom:/s/^/# /' /etc/apt/sources.list
sudo apt update

If apt update then finds nothing to install from, your sources have no network mirror at all. Add one with the examples below for Debian 13 (trixie) and Debian 12 (bookworm).

Debian apt error Media change: please insert the disc labeled Debian GNU/Linux

Why apt asks for the disc

During installation, Debian asks whether to use a network mirror. If you answered no, or the network wasn't up yet, the installer only lists the install medium as a package source. The line looks like this:

deb cdrom:[Debian GNU/Linux 12.8.0 _Bookworm_ - Official amd64 DVD Binary-1]/ bookworm contrib main

From then on, every apt install and apt update tries the CD-ROM first and stops with "Media change". The fix is the same on Debian 8 through 13; only the release names and file layout change.

Step 1: find the cdrom line

The source can be in the classic file or in the sources.list.d folder. Search both:

grep -rn "cdrom" /etc/apt/sources.list /etc/apt/sources.list.d/

Step 2: comment it out

Open the file it's in:

sudo nano /etc/apt/sources.list
Debian sources.list with a cdrom line

Put a # in front of every line that starts with deb cdrom:. Or do it in one command:

sudo sed -i '/^deb cdrom:/s/^/# /' /etc/apt/sources.list

If the cdrom source is in a .sources file (the newer deb822 format), add a line Enabled: no to that block instead.

Step 3: add the online Debian mirror

Debian 12 (bookworm), in /etc/apt/sources.list:

deb http://deb.debian.org/debian bookworm main contrib non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free-firmware
deb http://security.debian.org/debian-security bookworm-security main contrib non-free-firmware

Debian 13 (trixie) prefers the deb822 format. Create /etc/apt/sources.list.d/debian.sources:

Types: deb
URIs: http://deb.debian.org/debian
Suites: trixie trixie-updates
Components: main contrib non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: http://security.debian.org/debian-security
Suites: trixie-security
Components: main contrib non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

If you use the .sources file, leave /etc/apt/sources.list empty or with only commented lines, so the same repository isn't defined twice. On a system upgraded from 12, sudo apt modernize-sources converts the old file to the new format for you.

Not sure which release you have? Check with cat /etc/os-release. The Debian Wiki SourcesList page has examples for every release and explains the components.

Step 4: update

sudo apt update

You should now see deb.debian.org and security.debian.org in the output, and no more "Media change" prompt.

apt update using the online Debian mirror

On a desktop: the GUI way

On Debian with GNOME or KDE, open Software & Updates (or Software Sources), and on the first tab uncheck the entry for the CD-ROM/DVD ("Cdrom with Debian..."). Close the window and let it reload the package lists.

Older Debian versions (8 Jessie, 9 Stretch, 10 Buster)

The fix is the same: comment out the deb cdrom: line. But all three are out of support, and old releases get moved to archive.debian.org, so their regular mirror entries may stop working. If you're still on one, plan an upgrade. Debian 12 or 13 on a fresh install is usually less work than updating step by step.

My take

Always pick a network mirror during the Debian install, even if you install from the full DVD. It saves you this error and gets you security updates from the first boot. If you're setting up a server, the next things I'd do are a static IP and SSH key login.

FAQ

What does "Media change: please insert the disc labeled Debian GNU/Linux" mean?

apt is configured to use the installation DVD or USB as a package source. It can't find the disc, so it asks you to insert it. Remove the deb cdrom: line from your apt sources.

How do I remove the CD-ROM repository in Debian?

Comment out the deb cdrom: line in /etc/apt/sources.list with sudo sed -i '/^deb cdrom:/s/^/# /' /etc/apt/sources.list, then run sudo apt update.

What should sources.list look like on Debian 12?

Three lines: bookworm, bookworm-updates and bookworm-security, with the components main contrib non-free-firmware, pointing at deb.debian.org and security.debian.org.

Where are the apt sources on Debian 13?

Debian 13 prefers /etc/apt/sources.list.d/debian.sources in the deb822 format. The old /etc/apt/sources.list still works, but don't define the same repository in both.

Can I keep the DVD as a source?

You can, but there's no reason to on a machine with internet. The DVD never gets security updates.