LINUXMAKER, OpenSource, Tutorials

How to update Debian Linux 11 "Bullseye" to Debian Linux 12 "Bookworm"?

At the time of this writing, Debian Bullseye is already the OldStable version, while Debian Bookworm is already the stable version. Debian 12 Bookworm was set to stable in June 2023.
However, the procedure from an oldstable version to a stable version in Debian Linux is always the same. This procedure should be recorded and documented here.

Bookworm Full Upgrade

First, we're doing a full full upgrade of the existing Debian Stable System - currently Bullseye, which can be a bit more up-to-date with you.

# apt-get update
# apt list --upgradable

This updates the package lists and displays available updates without installing them.

# apt-get -y upgrade
# apt-get -y dist-upgrade

This brings the current stable system up to date. You can also omit the option "-y", but you will then be asked interactively whether the actions should be carried out. The above chain of commands updates the information from the repositories, updates all packages, but does not delete one. The last command performs a system upgrade that allows both packages to be installed and deleted.

Prepare the Package Repository on Debian "Bookworm"

As already said, this statement can be applied to any Debian version, regardless of the versions "Bullseye" and "Bookworm". In the next step we prepare the /etc/apt/sources.list for the upgrade.

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

After that, your /etc/apt/sources.list should look something like this:

deb bookworm main non-free-firmware
deb-src bookworm main non-free-firmware

deb bookworm-security main non-free-firmware
deb-src bookworm-security main non-free-firmware

deb bookworm-updates main non-free-firmware
deb-src bookworm-updates main non-free-firmware

Then we bring our system up to date with the Bookworm repository.

# apt-get update

System-Upgrade to Debian-Bookworm

The following commands will upgrade your Debian 11 Bullseye to a Debian 12 Bookworm.

# apt-get -y upgrade
# apt-get -y dist-upgrade

Check which Debian version is running on your Linux system

The easiest way to check which Debian version you are running is simply to read the contents of the /etc/issue file.

# cat /etc/issue
Debian GNU/Linux 12 \n \l

However, the above command does not show you the latest Debian upgrade versions. In the following example, the command already provides more detailed information:

cat /etc/debian_version

In the next step, you can also look through the release file /etc/os-release:

# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION="12 (bookworm)"

Another alternative is lsb_release, which may need to be installed first. Subsequently, this command also provides information about the Debian version on your Linux system.

# aptitude install lsb_release
#lsb_release -da
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:       12
Codename:       bookworm

For Debian versions that already use Systemd, you can also use hostnamectl:

   Static hostname: srv
         Icon name: computer-VM
           Chassis: vm
        Machine ID: 9e413e5b509343bc9a10c97172a75658
           Boot ID: 71224c76c174487abad3a9979a632ef4
  Operating System: Debian GNU/Linux 12 (bookworm)
            Kernel: Linux 5.10.0-23-amd64
      Architecture: x86-64