How to upgrade from Debian 11 to Debian 12

Estimated reading: 4 minutes 297 views

Hi, friends. But now you will learn how to upgrade from Debian 11 to Debian 12. It’s simple, but you have to be careful.\

Debian 12 comes as always with many new features, thousands of updated packages, and revamped desktop environments. So, it is no exaggeration to say that Debian 12 is one of the releases of the year.In addition to this, Debian 12 comes with a new policy for handling proprietary drivers that will make it easier to install.

Preliminary Considerations

Before starting, it is always a good idea to make a full backup of your most important data. It is also good to consider whether you really need the upgrade or a clean installation.

In any case, the backup should be done to prevent possible problems. Another issue to consider is the external repositories you have added. My advice is to remove them before upgrading.

Upgrading from Debian 11 to Debian 12

1. Update the System

Verify your operating system version using the following command:

lsb_release -a

You should see the following output:

If that’s not the case, you are most likely not running Debian 11 and should not follow this guide further. Otherwise, you can continue with the next step:

Now you must update and upgrade all your system packages to the latest version. Run the following command to update and upgrade all packages:

# apt update
# apt upgrade 
# apt full-upgrade

Next, remove all unwanted packages with the following command:

# apt autoremove

2. Update repository files

Now you have to touch the system repositories and point them to Debian 12. First, make a backup of the file.

# cp /etc/apt/sources.list /opt/sources.list.bak

Or any location you like. It is even a good idea to have a backup outside the computer.

Then, replace in the repository file replace in each entry bullseye by bookworm so that it points to the new version.

You can do this manually by editing the file or by executing

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

Or edit the APT source file manually with the following command:

# nano /etc/apt/sources.list

Replace “bullseye” with “bookworm”. The result should be similar to the one 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 and close the file when you are finished. If there are more APT source files in /etc/apt/sources.list.d/, edit these as well by replacing “bullseye” with “bookworm”

3. Upgrade the operating system from Debian 11 (bullseye) to Debian 12 (bookworm)

At this point, your server is ready for the upgrade.

First, update the repository to apply the changes you made in the previous step.

# apt update

Once this is done, run the following command to start the upgrade:

# apt full-upgrade

During the process, you will see a screen showing the changes to come. Press q to continue.

From here on, it is a matter of following the instructions on the screens you will see. To accelerate the process, tell the wizard that it can restart services without consulting you.

In some of them, you will be asked to choose whether to replace configuration files such as SSH versions with current ones. To keep everything running smoothly, keep the same version.

When finished, restart Debian.

# reboot

4. Verify the upgrade

Now, check that everything went well. Open a terminal and run.

lsb_release -a

Done!

Conclusion

Now that you know how to get Debian 12 from Debian 11, you can use it on your computer, but remember to use caution.