Seamlessly Transition from Debian 11 to Debian 12: A Step-by-Step Guide

Debian 12, codenamed “Bookworm,” was released on June 10, 2023. As a stable release, it will receive support for the next five years. This update includes popular packages such as Linux Kernel 6.1 LTS, Apache 2.4.57, and MariaDB 10.11, among others.

Before proceeding with the upgrade to Debian 12, ensure that you:

  • Backup all your files on an external drive.
  • Have a stable internet connection.

This guide will walk you through upgrading from Debian 11 (Bullseye) to Debian 12 (Bookworm) in a straightforward manner.

Update the System

Log in to your server as the root user. If you have not done so, you can switch to the root user by executing:

su -

Verify the current operating system version with the command below:

lsb_release -a

You should see output similar to this:

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

If you do not see this output, you might not be running Debian 11, and this guide may not apply. If confirmed, continue with the steps below.

Next, ensure all system packages are up-to-date by running:

apt-get update
apt-get upgrade
apt-get dist-upgrade

Remove unnecessary packages using:

apt-get autoremove

Reboot your system to apply all the updates:

reboot

Update Repository Files

We now need to update the repository source files to point to Debian 12 Bookworm.

You can automatically update all source entries by running:

sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list
sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*.list

Alternatively, manually edit the APT source file using this command:

nano /etc/apt/sources.list

Replace “bullseye” with “bookworm” as shown below:

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

Save your changes and close the file. If there are more APT source files in /etc/apt/sources.list.d/, apply the same change to replace “bullseye” with “bookworm”.

Starting with Debian 12 “Bookworm”, non-free firmware packages (like firmware-amd-graphics, firmware-iwlwifi, firmware-misc-nonfree) have moved to a separate archive component, “non-free-firmware”. Include this in your sources.list if necessary.

For example, change:

deb https://deb.debian.org/debian bookworm main

To:

deb https://deb.debian.org/debian bookworm main non-free-firmware

Upgrade the Operating System from Debian 11 (bullseye) to Debian 12 (bookworm)

Your server is now prepared for the upgrade.

First, update the repository with these new settings:

apt-get update -y

You may encounter prompts requiring your input, such as service restarts, configuration updates, or release notes. Address each prompt carefully, especially when comparing existing and new configuration files.

Update existing packages while preventing new installations:

apt-get upgrade --without-new-pkgs -y

Proceed with the full system upgrade:

apt-get full-upgrade -y

After the upgrade completes, reboot your server:

reboot

Verify the Upgrade

Verify the upgrade by running:

lsb_release -a

Your system should now report Debian 12, as seen below:

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm

Conclusion

Your server is now operating on the latest Debian LTS release. Should you encounter issues, seek assistance on our forum.

FAQs

Can I skip intermediate Debian versions when upgrading?
No, you should upgrade sequentially from one Debian release to the next to ensure system stability and compatibility.
What should I do if my upgrade fails?
If the upgrade process fails, refer to logs located in /var/log/, and seek guidance on relevant forums or consult Debian’s documentation.
Is a server reboot necessary after upgrading Debian?
Yes, a reboot ensures that all updates are correctly applied and that the server runs smoothly on the new Debian release.
What precautions should I take before upgrading?
Backup all critical data, verify a stable internet connection, and ensure the server is not in production to prevent disruptions.