Upgrade to Debian 12 from Debian 11



Published on 2024-03-17
Summary:

Upgrading from Debian 11 to Debian 12

First, update the packages index and upgrade:


sudo apt update
sudo apt upgrade
sudo apt dist-upgrade

Then, clean any residual packages and configuration files::


sudo apt autoremove
sudo apt autoclean

Check the current Debian version:


cat /etc/os-release

Make backups of your repository files:


sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp -r /etc/apt/sources.list.d /etc/apt/sources.list.d.bak

Once you have updated and cleaned your system, the next step is to upgrade the /etc/apt/sources.list file, as well as the files within your /etc/apt/sources.list.d folder.

In these files, you must replace all references from bullseye to bookworm, and from bullseye-updates to bookworm-updates.

Example of an updated /etc/apt/sources.list file:


deb http://deb.debian.org/debian bookworm main
deb-src http://deb.debian.org/debian bookworm main

deb http://deb.debian.org/debian-security/ bookworm-security main
deb-src http://deb.debian.org/debian-security/ bookworm-security main

deb http://deb.debian.org/debian bookworm-updates main
deb-src http://deb.debian.org/debian bookworm-updates main

Upgrade and clean the Debian distribution:


sudo apt update
sudo apt full-upgrade


sudo apt autoremove
sudo apt autoclean

Reboot:


sudo reboot

After rebooting, you can verify that the upgrade was successful by checking the Debian version information:


cat /etc/os-release

You should see output similar to:


PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

With the system successfully upgraded, you can now delete your old repository backup files to clean up your system:


sudo rm -f /etc/apt/sources.list.bak
sudo rm -r /etc/apt/sources.list.d.bak


With LEMP Server (for Debian 12 Upgrade)

If you are working with a LEMP (Linux / Nginx / MariaDB / PHP) server, it's essential to configure certain files before proceeding with the Debian distribution upgrade.

This example is based on Debian 12, Nginx, MariaDB 11.2, and PHP 8.3 configurations that were verified in March 2024.

Nginx:

To configure Nginx for Debian 12, follow these steps:

Open the Nginx repository file:


sudo nano /etc/apt/sources.list.d/nginx.list

Add the following line to the file:


deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/debian bookworm nginx

Nginx Documentation: Refer to the official Install Nginx on Debian documentation for more information.

MariaDB 11.2:

To configure MariaDB 11.2 for Debian 12, follow these steps:

Open the MariaDB repository file:


sudo nano /etc/apt/sources.list.d/mariadb.list

Add the following line to the file:


deb [arch=amd64 signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] https://deb.mariadb.org/11.2/debian bookworm main

MariaDB Documentation: Refer to the official Install MariaDB on Debian 12 documentation for more information.

PHP 8.3:

To configure PHP 8.3 for Debian 12, follow these steps:

Open the PHP repository file:


sudo nano /etc/apt/sources.list.d/php.list

Add the following line to the file:


deb https://packages.sury.org/php/ bookworm main

Update an upgrade Debian distribution:

Then, proceed with the Debian distribution upgrade using the following commands:


sudo apt update
sudo apt upgrade