How to upgrade Debian 10 to Debian 11 Bullseye using the CLI

Debian Linux 11 “Bullseye” has been released. The new version offers updated packages and five years of support. This page explains how to update Debian 10 Buster to Debian 11 Bullseye using command-line options, including upgrading all installed packages.

What’s new in Debian 11?

  • Apache 2.4.48
  • Bash 5.1.4
  • BIND DNS Server 9.16
  • Emacs 27.1
  • GNOME desktop 3.68
  • KDE desktop 5.20
  • Libreoffice 7.0
  • Lighttpd 1.4.59
  • Linux kernel 5.10.0-8
  • LXDE 11
  • LXQt 0.16
  • MariaDB 10.5
  • MATE 1.24
  • Nginx 1.18
  • OpenSSH 8.4p1
  • Perl 5.32.1
  • PHP 7.4
  • Postgresql 13
  • Python 3.9.2 (default but one can install Python 2.7.18 if needed)
  • Rustc 1.48
  • Vi IMproved (VIM) 8.2
  • Xfce 4.16.

Upgrade Debian 10 to Debian 11 Bullseye

The procedure is as follows:

  1. Backup the system.
  2. Update existing packages and reboot the Debian 10 system.
  3. Edit the file /etc/apt/sources.list using a text editor and replace each instance of buster with bullseye. Next find the security line, replace keyword buster/updates with bullseye-security.
  4. Update the packages index on Debian Linux, run:
    sudo apt update
  5. Prepare for the operating system minimal system upgrade, run:
    sudo apt upgrade --without-new-pkgs
  6. Finally, update Debian 10 to Debian 11 bullseye by running:
    sudo apt full-upgrade
  7. Reboot the Linux system so that you can boot into Debian 11 Bullseye
  8. Verify that everything is working correctly.

Let us see all commands step by step to upgrade Debian 10 Buster to Debian 11 Bullseye safely running in the cloud or bare metal environment.

Step 1. Backup your system

Warning! Do not skip the backup step. The author and nixCraft are not responsible for data loss and failed installation.

It is crucial to back up all data and system configurations. Cloud-based VMs can be quickly backup and restore using snapshots.

lsb_release command:
$ lsb_release -a
Here is what I see:

Note down the Linux Kernel Version too:
$ uname -mrs
My Linux kernel version:

Also note down the Debian version:
$ cat /etc/debian_version
Outputs:
10.11

Step 2. Update ALL existing installed packages

Any package in hold status will create a problem with upgrade procedure. Hence, list all packages hold from upgrades using the apt-mark command:
$ sudo apt-mark showhold | more
# OR #
$ sudo dpkg --get-selections | grep 'hold$' | more

Then remove the host status for all listed packages one-by-one with the following command:
$ sudo apt-mark unhold package_name
## OR ##
$ echo 'package_name install' | sudo dpkg --set-selections

See “apt-get hold back packages on Ubuntu / Debian Linux for more info. Before you upgrade your Debian version to 11, you must apply all security patches and pending upgrades to Debian 10 itself. Therefore, type the following apt command or apt-get command:
$ sudo apt update
$ sudo apt upgrade
$ sudo apt full-upgrade
$ sudo apt --purge autoremove

OR
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get full-upgrade
$ sudo apt-get --purge autoremove

Reboot the Debian 10.x buster to apply the kernel and other updates:
$ sudo systemctl reboot

Step 3. Update /etc/apt/sources.list file

Make sure you replace http://mirrors.linode.com/ APT URL mirror name with your actual mirror name.

Before starting the upgrade procedure, you must reconfigure APT’s source-list files. To view current settings using the cat command or more command$ more /etc/apt/sources.list
Old Debian 10 APT config file:

Old Debian 10.x /etc/apt/sources.list file
The keyword buster indicates that we are using an older version 10. Hence, we must change all the references in this file from Buster to Bullseye using a text editor such as vim:
$ sudo vi /etc/apt/sources.list
I prefer to use sed tool, but first backup all config files using the cp command:
$ sudo cp -v /etc/apt/sources.list /root/
$ sudo cp -rv /etc/apt/sources.list.d/ /root/

Edit the /etc/apt/sources.list file:
$ sudo vim /etc/apt/sources.list
Find the debian-security line for Buster:
deb http://mirrors.linode.com/debian-security buster/updates main
Replace with:
deb http://mirrors.linode.com/debian-security bullseye-security main
OR the following syntax is valid too:
deb http://mirrors.linode.com/debian-security bullseye-security/updates main
Then replace other buster line with bullseye in /etc/apt/sources.list and /etc/apt/sources.list.d/* directory. For example, find:
deb http://mirrors.linode.com/debian buster main
Replace with:
deb http://mirrors.linode.com/debian bullseye main
See updated file now:
$ cat /etc/apt/sources.list

Upgrading To Debian 11 Bullseye

Updating APT source list file to use Bullseye releaseFor your ready references, here is my updated APT config file that will update the system to Debian version 11 for Linode server:

Updated /etc/apt/sources.list file with Linode mirror
Here is my updated APT config file AWS Lightsail/EC2 server:

Updated /etc/apt/sources.list file for EC2 with AWS CDN

Updating the package list

Updating the package list for Debian 11

Then run:
$ sudo apt update

Step 4. Minimal system upgrade

Debian 10 to Debian 11 Minimal system upgrade

A two-part process is necessary to avoid the removal of large numbers of packages that you want to keep. Therefore, first run the following command to apply:
$ sudo apt upgrade --without-new-pkgs

Just follow on-screen instructions. During the upgrade process, you may get various questions, like “Do you want to restart the service? ” OR “keep or erase config options” and so on. For example, I got a screen as follows indicating new changes:

AWS Linode Debian 10.10 to Debian 11 upgrade

APT listing changes and showing news about package updates. Make sure you read them.Press ‘q‘ to exit and further you may see additional screens:

Restart Debian 11 services during package upgrades without asking

Make sure you choose the “Yes” option

Why do I get such prompts when upgrading system?

There are services installed on your system which need to be restarted when specific libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may cause service interruptions for the system, you will typically be prompted on each upgrade for the list of services you wish to restart. You can choose this option to avoid being prompted; instead, all necessary restarts will be done for you automatically so you can avoid being asked questions on each library upgrade.

Step 5. Upgrading Debian 10 to Debian 11

How to upgrade Debian 9 to Debian 10 Buster using the CLI

In addition, minimum upgrades we need to do full upgrades to finish the whole Debian 10 to Debian 11 update process. This is the main part of the upgrade. In other words, execute the following command to perform a complete upgrade of the system, installing the newest available versions of all packages, and resolving all possible dependency:
$ sudo apt full-upgrade

You may see additional prompts about restarting services or updating existing config options. Review those carefully too. For instance, I got an opportunity to update or keep the OpenSSH config file as follows:

What to do with OpenSSH config files on Debian 11. Replace or keep it

What do you want to do about modified config file?And you are done. It is time to reboot the Linux system to boot into Debian Linux 11 buster. Hence, run
$ sudo systemctl reboot
Outputs:

Try running the ping command to get notification when your server comes back online:
$ ping -a server_IP_here
ping -a 45.xx.zzz.yyy

Step 6. Verification

It is time to confirm the upgrade. Run:
$ uname -r
$ lsb_release -a

I get successful update confirmation:

After the upgrade, look out for all your apps and services. Therefore, verify all TCP/UDP ports are opened and services are running using the tail command or ss command or grep command/egrep command:

sudo ss -tulpn

sudo tail -f /var/log/mail.log

sudo tail -f /var/log/nginx/access_log

# look for errors if any

sudo grep ‘error’ /var/log/my_app/app1.log

sudo egrep -i ‘err|fail|warn|crit’ /var/log/nginx/python_app.log

# Check for service status

sudo systemctl status nginx.service

sudo systemctl status mariadb.service

# Use journalctl to query the contents of the systemd(1) journal

sudo journalctl

sudo journalctl -u sshd.service

A note about removing unwanted packages

WARNING! The following is an optional step. However, you must carefully review packages that are no longer needed on the system. Otherwise, the following command might break the system.

How to Upgrade Debian 10 Buster to Debian 11 Bullseye

Finally, clean up outdated packages using the apt command/apt-get command:
$ sudo apt --purge autoremove

A note about missing drivers or firmwares blobs

When you update the system from Debian 10 to 11, specific firmware stored on your system is disabled. Look into the kernel modules directory under /lib/ for disabled firmware. For example, you may see a Qualcomm firmware file named firmware-6.bin.disabled from the last upgrade. Those files need to be installed or upgraded again and reboot the system. The same goes for proprietary drivers like NVidia. Hence, making backups and not panicking is essential.

Summing up

And there you have it. We have successfully upgraded to Debian Linux 11. Updated Debian 11 version always brings new features and hardware support via Linux kernel. Hence, one must evaluate needs and then do upgrades. Debian Linux project also posted an in-depth guide that explains other issues one might face during installation. Make sure your read man pages using the man command:
$ man apt
$ man apt-get