At the time of writing, Buster is EOL in four months, 30 June, 2024. Bullseye is EOL until 2026 and Bookworm's EOL is 2028. For this entry I chose to go with Bullseye because I wanted to install Foreman on my backup server, which does not support Bookworm yet.
Although this is specifically written for upgrade from Debian 10, Buster to Debian 11, Bullseye, this can be applied to upgrading any version of Debian.
Requirements
There isn't much that you need other that time and maybe some extra storage for backups. If you plan on upgrading the system without backing anything up or already have backups, then this can be done within an hour. More time may be required if you have a lot of packages, slow connection, or run into issues with some of the installed software on the system.
Process
The process of upgrading major Debian releases isn't very difficult and most of it is just waiting around for packages to be downloaded and installed/upgraded.
Backup Your Data
In addition to any user data that you may have, you should backup the following system directories:
- /var/lib/apt
- /var/lib/aptitude (if you use aptitude)
- /var/lib/dpkg
- A list of currently installed packages on the system. (
dpkg --get-selections "*" > dpkg-selections
)
mkdir /mnt/external/upgrade
mkdir -p /mnt/external/upgrade{etc,home,root}
mkdir -p /mnt/external/upgrade/var/lib/{apt,aptitude,dpkg}
rsync -av /etc/ /mnt/external/upgrade/etc/
rsync -av /home/ /mnt/external/home/
rsync -av /root/ /mnt/external/root/
rsync -av /var/lib/apt/ /mnt/external/upgrade/var/lib/apt/
rsync -av /var/lib/aptitude/ /mnt/external/upgrade/var/lib/aptitude/
rsync -av /var/lib/dpkg/ /mnt/external/upgrade/var/lib/dpkg/
dpkg --get-selections "*" > /mnt/external/dpkg-selections
Ensure System is Up-To-Date
# View a lit of packages being held back
apt-mark showhold | more
# Unhold those packages
apt-mark unhold
apt-get update
apt-get upgrade
apt-get full-upgrade
# I had to install this package because the upgrade failed. You may or may not need this package installed.
apt-get install -y gcc-8-base
Update the apt source files
Change the code-name of your release that is found in the source files, for example, /etc/apt/sources.list:
sed -i -e 's/buster/bullseye/g' /etc/apt/sources.list
Make sure that you update any additional files located in the /etc/apt/sources.list.d directory as well. For versions after buster, you must update the security sources. Instead of simply buster, it's now bullseye-security and bookworm-security.
# For Buster:
deb http://security.debian.org/debian-security buster/updates main contrib non-free
deb-src http://security.debian.org/debian-security buster/updates main contrib non-free
# For Bullseye
deb http://security.debian.org/debian-security bullseye-security/updates main contrib non-free
deb-src http://security.debian.org/debian-security bullseye-security/updates main contrib non-free
Update the System
apt-get clean
apt-get update -y
apt-get upgrade -y
apt-get full-upgrade -y
Reboot and Verify
systemctl reboot
cat /etc/debian_version
Cleaning Up
apt autoremove -y
TL;DR
BACKUP_ROOT=/mnt/external/upgrade
CURRENT_VERSION=buster
NEW_VERSION=bullseye
mkdir $BACKUP_ROOT
mkdir -p $BACKUP_ROOT/{etc,home,root}
mkdir -p $BACKUP_ROOT/var/lib/{apt,aptitude,dpkg}
rsync -av /etc/ $BACKUP_ROOT/etc/
rsync -av /home/ $BACKUP_ROOT/home/
rsync -av /root/ $BACKUP_ROOT/root/
rsync -av /var/lib/apt/ $BACKUP_ROOT/var/lib/apt/
rsync -av /var/lib/aptitude/ $BACKUP_ROOT/var/lib/aptitude/
rsync -av /var/lib/dpkg/ $BACKUP_ROOT/var/lib/dpkg/
dpkg --get-selections "*" > $BACKUP_ROOT/dpkg-selections
apt-mark showhold | more
apt-mark unhold
apt-get update
apt-get upgrade -y
apt-get full-upgrade -y
apt-get install -y gcc-8-base
sed -i -e "s/$CURRENT_VERSION/$NEW_VERSION/g" /etc/apt/sources.list
apt-get clean
apt-get update
apt-get upgrade -y
apt-get full-upgrade -y
systemctl reboot