Ceci est une ancienne révision du document !
Debian Linux 12 “Bookworm” has been released. As of 23/July/2023, Debian 12.6 point was released on the 29 june 2024. The new version offers updated packages and five years of support. This page provides a step-by-step guide to updating Debian 11 Bullseye to Debian 12 Bookworm using command-line options, including upgrading all installed packages.
The procedure is as follows:
/etc/apt/sources.list
using a text editor and replace each instance of bullseye with bookworm. Next find the update line, replace keyword bullseye-updates with bookworm-updates. Finally, search the security line, replace keyword bullseye-security with bookworm-security.frater@host:~$ sudo apt update
frater@host:~$ sudo apt upgrade --without-new-pkgs
frater@host:~$ sudo apt full-upgrade
Let us see all commands step by step to upgrade Debian 11 Bullseye to Debian 12 Bookworm safely running in the cloud or bare metal environment.
It is essential to complete the backup process to avoid any data loss or installation failure. The responsibility for keeping verified backups lies with the user, as this is a fundamental lesson for sysadmins. The author and nixCraft cannot be held accountable for any issues that arise due to a lack of backup.
Backing up all data and system configurations is extremely important. To do this efficiently, cloud-based virtual machines can be quickly backed up and restored using snapshots. Check os version in Linux using the lsb_release
command.
frater@host:~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye
Note down the Linux kernel version too. Try the uname
command:
frater@host:~$ uname -mrs Linux 5.10.0-23-amd64 x86_64
Also note down the Debian version using the cat
command:
frater@host:~$ cat /etc/debian_version 11.7
To make the upgrade safer, you must remove non-Debian packages.
For example, Google Chrome or VirtualBox is a non-Debian package installed using 3rd party repo. Those can create a problem. Here is how to find such pages:
frater@host:~$ sudo apt list '?narrow(?installed, ?not(?origin(Debian)))' frater@host:~$ sudo apt-forktracer | sort
Fortunately, I don’t rely on Google Chrome, VirtualBox, or any third-party applications on Debian.
However, if you use these apps, you should back up your data before upgrading. After upgrading, you can reinstall these packages if the Bookworm release supports them. Also, any package in hold status will create a problem with the upgrade procedure. Therefore, list all packages hold from upgrades using the apt-mark command as follows:
frater@host:~$ sudo apt-mark showhold | more
## OR ##
frater@host:~$ sudo dpkg --get-selections | grep 'hold$' | more
Then you must delete or remove the host status for all listed packages one by one with the help of the following command:
frater@host:~$ sudo apt-mark unhold package_name
## OR ##
frater@host:~$ echo 'package_name install' | sudo dpkg --set-selections
Before you upgrade your Debian version to 12, you must apply all security patches and pending upgrades to Debian 11 itself. Therefore, type the following apt command or apt-get command:
frater@host:~$ sudo apt update Hit:1 http://deb.debian.org/debian bullseye InRelease Get:2 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB] Hit:3 http://deb.debian.org/debian bullseye-security InRelease [48.4 kB] Fetched 92.4 kB in 2s (138 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. frater@host:~$ sudo apt upgrade frater@host:~$ sudo apt full-upgrade
frater@host:~$ sudo apt --purge autoremove
Reboot the Debian 11.x bullseye to apply the kernel and other updates using the “reboot” or “shutdown” command. For instance:
frater@host:~$ sudo systemctl reboot
To begin the upgrade process, it is necessary to reconfigure the source-list
files of APT.
You can view the current settings by using the commands cat command or more command. This will display the list of Debian 11 repo URLs.
frater@host:~$ sudo cat /etc/apt/sources.list
deb http://deb.debian.org/debian bullseye main deb http://deb.debian.org/debian bullseye-updates main deb http://deb.debian.org/debian-security/ bullseye-security main
The keyword bullseye indicates we are using an older version, 11. Hence, we must change all the references in this file from bullseye to bookworm using a text editor such as Vim or Nano. For example: sudo cp -v /etc/apt/sources.list /root/sources.list-bakup.11.bullseye
sudo vim /etc/apt/sources.list
From:
deb http://deb.debian.org/debian bullseye main deb http://deb.debian.org/debian bullseye-updates main deb http://deb.debian.org/debian-security/ bullseye-security main
To:
deb http://deb.debian.org/debian bookworm main deb http://deb.debian.org/debian bookworm-updates main deb http://deb.debian.org/debian-security/ bookworm-security main
Save and close the file. You can also use the sed command to find and replace bullseye with bookworm as follows:
sudo sed -i'.bak' 's/bullseye/bookworm/g' /etc/apt/sources.list Upgrading To Debian 12 Bookworm
Updating APT source list file to use Bookwork release A note about the non-free-firmware repo
If you intend to use Debian 12 on either a desktop or server that requires non-free firmware for hardware such as WiFi, GPU, Sound, Nvida/AMD GPU, NIC and more, it is recommended to include the non-free firmware repository. Below is the updated file /etc/apt/sources.list file. The orange color repo config indicates that non-free firmware is required for your hardware. If you’re unsure about your hardware, I suggest adding those repositories.
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
Updating the package list
Finally, run the following command to get fresh apt repo data:
sudo apt update Updating the package list for Debian 12 Linux
Click to enlarge