How To Upgrade Debian to Debian 11 Bullseye

Debian 9 will end of life (EOL) in a few months, if you can’t re-install the Debian and copy the files over then upgrade is another option for you. The first rule before doing an upgrade, back up the important files. The system sometimes failed, but for sure it’ll fail, time will tell when it happens, so better save than sorry.

It’s not save the running server on the EOL operating system, so it is highly recommended to upgrade if you running Debian 9. Even if we give an example for Debian 9, this tutorial works on upgrading Debian 10 to Debian 11.

– Debian 9 or Debian 11
– root access
– Server had internet access

Get information about the installed Debian

uname -a
# output
Linux linux-server 4.9.0-18-amd64 #1 SMP Debian 4.9.303-1 (2022-03-07) x86_64 GNU/Linux

Get the Debian version

cat /etc/os-release
# output
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION="9 (stretch)"

1. Upgrade to Debian 11 using APT

We’ll use the APT package manager to perform the installation and upgrade process. The best practice for upgrading the Debian version is to disable the 3rd party first, and then gradually update the repository one by one.

Clean APT cache

In some cases, it’s really important due to the limited disk size to clear the APT caches.

sudo apt clean all

Update the repository to Debian 11 (bullyes), replace /etc/apt/sources.list with

deb bullseye main contrib non-free
deb bullseye-updates main contrib non-free
deb bullseye-security main contrib non-free

if you using 3rd party repository check /etc/apt/sources.list.d/ directory, and refer to their documentation to update to Debian 11.

Update APT metadata

sudo apt update

Upgrade the Packages

Install the newest versions of all packages currently installed on the system

sudo apt upgrade -y

To avoid some error in the upgrade, we need to run dist-upgrade to install or remove packages as necessary to complete the upgrade

sudo apt dist-upgrade -y
# or
sudo apt full-upgrade -y

Don’t leave it unattended, because it may asking to choose the option, just pickup the default, you can working on this later after the upgrade
default config

The server need to rebooted to finalize the upgrade process.

sudo reboot

2. Verify the Upgrade

After the server reboot, we’ll verify if the upgrade success or not by running uname -a and cat /etc/os-release, this two command only verify from the Debian version, not your application which you need to check it manually, refer to each application documentation for sure.
Check the kernel

uname -a
# output
Linux linux-server 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64 GNU/Linux

Get the Debian version

$ cat /etc/os-release
# output
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION="11 (bullseye)"

3. Cleanup after Upgrade

The upgrade left some orphaned packages, clean up these packages

sudo apt --purge autoremove

even after cleaning, some packages may still there

# debian 9
sudo dpkg -l | grep deb9
# debian 10
sudo dpkg -l | grep deb10

leftover debian 9

As you can see from the image above, there’s still Debian 9 left, which we don’t use anymore. It’s safe to remove that kernel

sudo apt purge PACKAGE-NAME -y
# example
sudo apt purge linux-image-4.9.0-11-amd64 -y

Leave a Reply