How to upgrade from Debian 11 Bullseye to Debian 12 Bookworm
Table of Contents
1 Before you begin
In this guide, we will upgrade a Debian 11 server to Debian 12
Backup
Before we get started, we'll take a full backup of the server
Check disk space
Also check there is enough free disk space to do the upgrade
df -h
Check Debian OS version
cat /etc/*-release
cat /etc/debian_version
Check third party repositories
Any third party repositories will also need to be updated for Debian 12 sources and the applications upgraded
ls /etc/apt/sources.list.d/
Install updates and reboot
Refresh apt sources, install updates and restart
# install updates
apt update
apt upgrade
# restart
systemctl reboot
2 Edit apt sources
Edit apt sources and change to Debian 12 Bookworm
nano /etc/apt/sources.list
apt sources.list before changes
# main
deb http://archive.debian.org/debian bullseye main contrib non-free
deb-src http://archive.debian.org/debian bullseye main contrib non-free
# security
deb http://archive.debian.org/debian-security bullseye-security main contrib non-free
deb-src http://archive.debian.org/debian-security bullseye-security main contrib non-free
# bullseye-updates, previously known as 'volatile'
deb http://archive.debian.org/debian bullseye-updates main contrib
deb-src http://archive.debian.org/debian bullseye-updates main contrib
# bullseye-backports
deb http://archive.debian.org/debian bullseye-backports main
Debian 11 is end of life so the updates source is archive.debian.org this will need to be changed to deb.debian.org
In Debian 12 the non-free component has been split into non-free and non-free-firmware sources
main
replace archive.debian.org with deb.debian.org
replace bullseye with bookworm
# main
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
security
replace archive.debian.org with security.debian.org
replace bullseye-security with bookworm-security
# security
deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
updates
replace archive.debian.org with deb.debian.org
replace bullseye-updates with bookworm-updates
# bookworm-updates, previously known as 'volatile'
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
backports
replace archive.debian.org with deb.debian.org
replace bullseye-backports with bullseye-backports
# bookworm-backports
deb http://deb.debian.org/debian bookworm-backports main contrib non-free
deb-src http://deb.debian.org/debian bookworm-backports main contrib non-free
New apt sources.list for Bullseye
# main
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
# security
deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# bookworm-updates, previously known as 'volatile'
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
# bookworm-backports
deb http://deb.debian.org/debian bookworm-backports main contrib non-free
deb-src http://deb.debian.org/debian bookworm-backports main contrib non-free

3 Update third party repos
Edit apt sources for any third party repositories and make sure they are pointing to the latest version that is compatible with Debian 12
ls /etc/apt/sources.list.d/
We're not covering these step by step in this guide because each application will be different
4 Run minimal upgrade
Run minimal upgrade first before running the full OS upgrade
# refresh apt packages
apt update
# run minimal upgrade
apt upgrade --without-new-pkgs
You will get prompted to confirm any package changes or changes to config files
Installation finished. No error reported.

Restart
systemctl reboot
5 Run full upgrade
Run the full OS upgrade
apt full-upgrade

Again, you will get prompted for any package changes that need you to confirm
Full upgrade completed

Restart
# reboot
systemctl reboot
Check OS version
cat /etc/debian_version
cat /etc/*-release
Debian has been upgraded to 12 Bookworm

6 Clean up apt packages
Clean up old apt packages using apt autoremove
apt update
apt upgrade
The following packages were automatically installed and are no longer required

apt autoremove
Package clean up completed
