Debian 11 End of Life: Upgrade to Debian 12 Safely
Debian 11 no longer gets security updates, and Debian only supports upgrading one release at a time. Here is the order of operations that keeps a server bootable.
Debian 11 bullseye is end of life. Its long-term support ended on 31 August 2026, and from September Debian provides no further security updates for it. A server still on Debian 11 keeps working, which is exactly the problem: nothing breaks, so the unpatched vulnerabilities pile up unnoticed.
Check what you are running and what could get in the way
Confirm the release first, then look for anything unusual that an upgrade could trip over: held packages, half-configured packages and repositories that are not Debian's.
cat /etc/debian_version
sudo dpkg --audit
apt-mark showhold
grep -rE '^(deb |URIs:)' /etc/apt/sources.list /etc/apt/sources.list.d/
dpkg --audit lists packages that are half-installed or failed to configure, and apt-mark showhold lists packages pinned in place. The official notes tell you to fix or release both before you begin. Any repository in that last list that is not deb.debian.org or security.debian.org is a third-party source. Check that it publishes packages for Debian 12, and disable it for the upgrade if it does not.
Prepare so that a failure is recoverable
First bring the machine fully up to date on bullseye, because the upgrade is only supported from the latest point release.
sudo apt update
sudo apt full-upgrade
sudo apt autoremove
Then take the backups that the Debian release notes list: /etc, the package database in /var/lib/dpkg, APT's extended state file, and a list of your package selections. If this is a virtual server, also take a snapshot at your provider. A snapshot is the quickest way back if the machine stops booting, which a copy of /etc cannot fix.
sudo tar czf /root/pre-upgrade-backup.tgz /etc /var/lib/dpkg /var/lib/apt/extended_states
dpkg --get-selections '*' > ~/dpkg-selections.txt
sudo apt install gpgv
Finally record the session, so that you can read exactly what happened if a prompt scrolls past. The notes use the script command for this, and ideally you run it inside tmux or screen so a dropped SSH connection does not interrupt the upgrade.
script -t 2>~/upgrade-bookworm.time -a ~/upgrade-bookworm.script
Point APT at bookworm
In /etc/apt/sources.list and any file in /etc/apt/sources.list.d/, replace the bullseye codename with bookworm. Nothing should still mention bullseye afterwards. A normal line looks like deb https://deb.debian.org/debian bookworm main contrib. If you use firmware from the non-free section, Debian 12 moved it into a new component, so add non-free-firmware to the line.
sudo cp /etc/apt/sources.list /root/sources.list.bullseye
sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list
grep -rn bullseye /etc/apt/sources.list /etc/apt/sources.list.d/
sudo sed -i 's|archive.debian.org/debian-security|security.debian.org/debian-security|' /etc/apt/sources.list
That last command should print nothing. If it does, either fix the remaining lines or comment them out. Do not run the upgrade with a leftover bullseye line, because APT will try to mix two releases.
Upgrade in two steps
Debian's notes split the upgrade into a minimal one and a full one. The minimal upgrade installs new versions of what you already have without adding or removing packages. The full upgrade then handles everything else, including dependency changes.
sudo apt update
sudo apt upgrade --without-new-pkgs
dpkg -l 'linux-image*' | grep ^ii | grep -i meta
sudo apt full-upgrade
The dpkg -l line checks that a kernel metapackage such as linux-image-amd64 is installed. If it prints nothing, install one before the full upgrade so the machine has a kernel to boot. If full-upgrade stops with "Could not perform immediate configuration", Debian's workaround is sudo apt full-upgrade -o APT::Immediate-Configure=0.
When it finishes, reboot to load the new kernel. Doing the upgrade and the reboot in a quiet maintenance window, with console access available, is worth more than any command in this guide.
Verify it worked and clean up
cat /etc/debian_version
uname -r
systemctl --failed
sudo apt update && apt list --upgradable
/etc/debian_version should now report 12, systemctl --failed should be empty or only list things you already knew were broken, and apt update should complete without errors about missing repositories. Open the sites and check the databases before you declare victory. Then clean up the leftovers.
sudo apt autoremove
sudo apt purge '~c'
apt list '~o'
find /etc -name '*.dpkg-*' -o -name '*.ucf-*' -o -name '*.merge-error'
apt purge '~c' removes packages whose configuration files remain after removal. Review the obsolete list from apt list '~o' before you purge it, because purging also deletes those packages' logs. The find command shows the configuration files the upgrade wrote next to yours, so you can compare them with diff.
Plan the second hop to Debian 13
Debian 12 is supported until 30 June 2028, so you have time, but a server parked on oldstable still needs a plan. The same procedure applies from 12 to 13, with a few changes in the release notes: APT sources live in the newer .sources format, the notes tell you to replace bookworm with trixie for the main, updates and security suites, and they finish by running apt modernize-sources. Read the notes for the exact release before you start, and run the whole procedure again, including the backups.
If you cannot upgrade yet
Some servers cannot move this month because of an application that only supports Debian 11. Debian's announcement says a subset of bullseye packages will be supported by external parties and points to its Extended LTS page, so read what is covered before you rely on it. Until you upgrade, reduce exposure: limit which networks can reach the machine, remove services you do not use, and keep a firm date for the upgrade.
Repeating the preflight checks on every Debian server you own is where this drags. BashPilot can run them as one request: it reads the OS release, held packages, third-party repositories and free disk space on each server, and stops for your approval before it changes sources or starts an upgrade. For a similar fleet-wide migration pattern, see how to migrate a cPanel account to a new server.
Checking Debian servers before an upgrade
Read-only check of 9 Debian servers. Three are on Debian 11. Two look ready, and one has a held package and a third-party repository to resolve first. Nothing has been changed.
| Server | Release | Held packages | Third-party repos | Free space on / |
|---|---|---|---|---|
| db01 | 11 | none | none | 18 GB |
| app02 | 11 | none | none | 22 GB |
| app03 | 11 | 1 | 1 | 9 GB |
Listing it is read-only. I will not release the hold without your approval.
apt-mark showhold
Try this on one of your own servers.
Start free trial