How to update Debian 11 to Debian 12

How to update Debian 11 to 12 in a nutshell.

Debian 11 (Bullseye) will become EOL (End of Life) around July 2024 it is time to upgrade.

Make a backup of the server

Before updating it is a good idea to make a server backup. Most Cloud providers like DigitalOcean offer snapshot backups.

Prepare the upgrade and check the OS Version in Linux

This command will show you the OS version:

$ lsb_release -a
lsb_release -a

Check the Linux kernel version:

$ uname -mrs
uname -mrs

Check the version number of Debian:

$ cat /etc/debian_version

Step 1: Update existing packages and reboot the Debian 11

Update Debian packages:

$ sudo apt update && sudo apt upgrade -y

Remove unnecessary packages:

$ sudo apt --purge autoremove 

Step 2: Edit the file sources.list

Edit the file sources.list and replace each instance of bullseye with bookworm. Find the update line, and replace the keyword bullseye-updates with bookworm-updates. Search the security line, replace keyword bullseye-security with bookworm-security

I like to use Nano to edit files:

$ nano /etc/apt/sources.list
nano /etc/apt/sources.list update Debian 11 to 12

You can also use the sed command to replace all instances of bullseye:

$ sudo sed -i'.bak' 's/bullseye/bookworm/g' /etc/apt/sources.list

Step 3: Upgrade to Debian 12

Update the repositories:

$ sudo apt update
sudo apt update

 Upgrade the existing packages:

$  sudo apt upgrade --without-new-pkgs

This will update the existing packages, you can get some interaction screens with questions, read carefully, and follow the on-screen instructions.

Do a full system upgrade to Debian 12:

$ sudo apt full-upgrade

Reboot the server:

$ sudo systemctl reboot

Step 4: Verify the Debian version and clean up the packages

Verify the Debian & Linux version:

$ lsb_release -a
$ cat /etc/debian_version

Clean up outdated and unnecessary packages:

$ sudo apt --purge autoremove

Re-run updates to verify all packages have been updated and cleaned up:

In some cases, I noticed that not all packages were updated. The “autoremove” command also indicated that some packages were not updated.

Run a second (regular) package upgrade:

$ sudo apt update -y && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y

When the server is finished updating all packages and you have followed the instructions for interaction screens during the upgrade you should repeat the verify process reboot and clean up again.

The following packages have been kept back

If you get a notification some packages have been kept back, which happens regularly when you run updates you can use this command to update the packages:

$ sudo apt-get --with-new-pkgs upgrade <list of packages kept back>

Interaction screens during the upgrade

Here are some interaction screens I got during the upgrade and the answers I gave in my case. The questions or interactions are different per installation and you may get other questions depending on your situation. Those answers may not be suitable for every situation but they will work for most installations.

postfix internet site
Choose: Y
Select the keep the local version currently installed option, and then choose <OK>
Select the keep the local version currently installed option, and then choose <OK>


Updating Debian 11 to 12 is not so hard, this comprehensive instruction will help you upgrade Debian. The upgrade will take about 30 minutes, excluding the time to make a server snapshot or backup.

It is a good practice to update the server regularly and upgrading Debian 11 to 12 will facilitate longer support and system updates. According to the Debian Project, Debian 11 (Bullseye) will become EOL (End of Life) around July 2024.

According to the Debian Wiki, Debian 12 (Bookworm) estimated EOL (End of Life) is around 2028.

If you use Debian and a control panel like Cloudpanel it is cleaner to set up a new Debian 12 server and migrate all sites over.

Leave a Comment