Upgrading to Debian 12 from Debian 11: A Step-by-Step Guide

This step-by-step guide shows you how to safely upgrade to Debian 12 "Bookworm" from Debian 11 "Bullseye" to enjoy the latest features!

On June 10, 2023, the Debian Project released a stable version of Debian 12, introducing many new features. Hence, users are eager to experience the latest innovations, security enhancements, and software updates it brings.

The Bookworm release will receive security updates from the Debian Security team until June 10, 2026, when it will enter its LTS phase, extending its support beyond 2026 by at least two more years, i.e., until June 2028.

Given the release’s intended five years of support, upgrading to Bookworm will provide users with peace of mind for their servers and desktop PCs for years to come.

So, in this step-by-step guide, we will walk you easily through the process of upgrading to Debian 12 “Bookworm” from Debian 11 “Bullseye,” covering key points and essential steps to successfully navigate this major version transition.

Step 1: Perform a System Backup

Backing up your essential files and configurations is highly recommended. In this light, we recommend making a full system backup so that if something goes wrong, you can restore your system with all the vital data to its previous state.

In addition, you can always use a command like the one shown below, which will archive all of the more critical directories and their contents in a tar.gz archive.

sudo tar czf /bullseye.tar.gz \
     --exclude=/bullseye.tar.gz \
     --exclude=/dev \
     --exclude=/mnt \
     --exclude=/proc \
     --exclude=/sys \
     --exclude=/tmp \
     --exclude=/media \
     --exclude=/lost+found \
     /Code language: JavaScript (javascript)

Feel free to add more โ€œโ€“exclude=โ€ parameters if needed. Finally, the command creates a backup of all files in โ€œbullseye.tar.gzโ€ located on the root partition (/), which you should ideally transfer to another computer or drive, for example, using the SCP command.

Step 2: Update All Currently Installed Packages

Before upgrading to Debian 12 from Debian 11, it is essential to ensure your currently installed Debian 11 system is up to date. Run the following APT commands in the terminal.

sudo apt update
sudo apt upgrade
sudo apt full-upgrade

If any updates are available, install them, then clean any leftover packages.

sudo apt --purge autoremove

Finally, reboot the system.

sudo reboot

After the system boot, log in. Below is our current fully-updated Debian 11 “Bullseye” system before we upgrade to Debian 12 “Bookworm.”

Debian 11 before starting the upgrade to Debian 12.
Debian 11 before starting the upgrade to Debian 12.

Step 3: Check for Installed Non-Debian Packages

Before proceeding with the upgrade to Bookworm, following best practices, we will check if any additional packages currently installed on our system are from somewhere other than the official Debian 11 repositories.

We do this because it is possible that when we have used our Debian 11 system, we have installed additional server or client software not from the Debian repositories, for example, Google Chrome, VirtualBox, etc.

However, this may cause complications when upgrading to Debian 12, as these external repositories may not yet be set up to work with the Bookworm release.

sudo apt list '?narrow(?installed, ?not(?origin(Debian)))'Code language: PHP (php)
Check for installed packages from non-Debian repositories.
Check for installed packages from non-Debian repositories.

As we can see, our check showed that, in this case, we have a Docker and Google Chrome installation that is from non-Debian repositories. So what do we do in such a situation?

Our best and recommended advice is, if the installed software is not critical to your needs, to uninstall it and reinstall it after successfully upgrading to Debian 12 to avoid issues during the upgrade.

However, in this case, with Docker and Google Chrome, since the software is from proven companies that immediately made their software compatible with Debian 12, we will continue upgrading to Bookworm without removing it.

But we’ll repeat it โ€“ do the necessary compatibility checks first.

In addition, check for packages that, for some reason, you have specified not to be updated. You can do this by running:

sudo apt-mark showhold

If the command doesn’t return anything, it is okay to move on. However, if you get a list of package names, you must allow them to be updated, as for each manually executed:

sudo apt-mark unhold package_name

Step 4: Update Software Sources Files

The Debian software repositories are defined in the “/etc/apt/sources.list” file and the “/etc/apt/sources.list.d/” directory. Before upgrading, you must reconfigure them to point to the Debian 12 “Bookworm” repositories.

It is a good practice before updating the software repositories’ configuration files to back up the current ones first.

mkdir ~/apt
cp /etc/apt/sources.list ~/apt
cp -r /etc/apt/sources.list.d/ ~/aptCode language: PHP (php)

Now you can update the current Debian 11 “Bullseye” repositories to those of Debian 12 “Bookworm.”

sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list
sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*Code language: PHP (php)

The above commands will replace the “bullseye” keyword with “bookworm” in software repository files.

Additionally, open the “/etc/apt/sources.list” file and add after each repository the new Debian 12’s “non-free-firmware” one.

After the changes, the final version of your “sources.list” file should contain the following lines:

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

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

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-firmwareCode language: JavaScript (javascript)
Debian 12's sources.list file.
Debian 12’s sources.list file.

Step 5: Perform an Initial Minimal Upgrade

At this point, your Debian 11 system is ready to be upgraded to Debian 12. The first step is to update the repository to let the system recognize the newly added repo URLs.

sudo apt update
Packages that are waiting for an update.
Packages that are waiting for an update.

You’ll be informed that plenty of packages are waiting to be upgraded. That’s fine, and we can move on.

The Debian developers recommend a two-part upgrade process as a best practice, so we’ll proceed that way.

  • Part 1: Minimal system upgrade
  • Part 2: Full system upgrade

In the minimal upgrade, you will update and upgrade all the available packages without installing or removing any other packages. Run the command shown below.

sudo apt upgrade --without-new-pkgsCode language: JavaScript (javascript)
Debian 12 minimal upgrade.
Debian 12 minimal upgrade.

Keep an eye on the screen – it will show you important information about some upgraded packages. Press “q” after reading to exit the pager and continue the upgrade.

Important information about any of the updated packages.
Important information about any of the updated packages.

In addition, the upgrade process will prompt for permission to restart services without asking. Choose “Yes” and hit “Enter.”

Accept services to be auto-restarted.
Accept services to be auto-restarted.

At the same time, you may also be asked what you want to do with a specific configuration file. If youโ€™re unsure what to do, go with defaults by pressing the “Enter” key to continue with the upgrade.

Preserve changes to modified files.
Preserve changes to modified files.

Step 6: Upgrade to Debian 12 “Bookworm” from Debian 11″Bullseye”

Once the minimal system upgrade completes, run the following command to begin the full upgrade.

sudo apt full-upgrade

Again, keep an eye on the screen, read the notifications, and perform the necessary actions required for the upgrading process to proceed.

Once everything is complete, reboot the system.

sudo reboot

Log in and enjoy your newly upgraded Debian 12 “Bookworm” system when the system boots.

Successfully upgraded to Debian 12 "Bookworm" from Debian 11 "Bullseye."
Successfully upgraded to Debian 12 “Bookworm” from Debian 11 “Bullseye.”

Step 7: Cleaning up Obsolete Packages

Finally, clean your newly upgraded Debian 12 system by removing obsolete packages that are now leftover from your successful upgrade and are not needed anymore.

sudo apt --purge autoremove

Conclusion

Upgrading to Debian 12 “Bookworm” from Debian 11 “Bullseye” is an easy and seamless process with the proper knowledge and careful execution. This step-by-step guide provides a comprehensive overview of the necessary procedures to ensure a successful upgrade.

By following these steps, users can take advantage of the latest features and improvements offered by Debian 12 while maintaining system stability and security.

For additional help or useful information, we recommend you check the official Debian upgrade documentation.

Finally, thank you for trusting our step-by-step instructions and relying on our expertise. I hope you have found our guide helpful.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%