Hello,
In this week’s feature highlight, we look at How to Upgrade Debian 11 to Debian 12
It is important to backup all your data before proceeding with the upgrade so that you can always revert to the previous version if anything goes wrong during the upgrade.
Upgrade all your existing packages
Upgrade all your existing packages. Use the following code to upgrade the packages.
apt update && apt upgrade -y
Modify package repository
Before you change anything, make sure to create a backup,
cp -v /etc/apt/sources.list /opt/sources.list-bakup-debian11
Output:
root@vps:~# cp -v /etc/apt/sources.list /opt/sources.list-bakup-debian11
'/etc/apt/sources.list' -> '/opt/sources.list-bakup-debian11'
Now use sed commands to replace the text ‘bullseye’ with ‘bookworm’ in the package repository file
sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list
Now, you need to update the packages to apply changes.
apt update
Output:
root@vps:~# apt update
Get:1 http://deb.debian.org/debian bookworm InRelease [147 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
Get:3 http://security.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:4 http://deb.debian.org/debian bookworm/main Sources [9,628 kB]
Get:5 http://deb.debian.org/debian bookworm/main amd64 Packages [8,904 kB]
Before starting the upgrade, let’s verify the current version using the following command,
root@vps:~# cat /etc/os-release
Output:
root@vps:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Upgrade to Debian 12
Run the update command,
apt update -y
This might take a long time to complete due to the number of packges involved in this process!
Once all the packages are updated in your system, then upgrade your distribution packages,
apt dist-upgrade -y
Output:
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for libc-bin (2.36-9) ...
Errors were encountered while processing:
dbus-daemon
dbus-user-session
dbus
libpam-systemd:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
During this if any client gets this error, then ask the client to run the below 3 commands and it will be fixed,
/usr/bin/dbus-uuidgen > /etc/machine-id
dbus-uuidgen >/var/lib/dbus/machine-id
apt update
apt dist-upgrade
Output:
root@vps:~# apt dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
libcbor0 libicu67 libldap-2.4-2 libmpdec3 libperl5.32 libpython3.9-minimal libpython3.9-stdlib liburing1 libusb-0.1-4
perl-modules-5.32 python3.9 python3.9-minimal telnet
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up dbus-daemon (1.14.6-1) ...
Setting up dbus (1.14.6-1) ...
A reboot is required to replace the running dbus-daemon.
Please reboot the system when convenient.
dbus.service is a disabled or a static unit, not starting it.
Setting up libpam-systemd:amd64 (252.6-1) ...
Setting up dbus-user-session (1.14.6-1) ...
Now, Remove the unused packages using below command,
apt autoremove -y
Verify Debian 12 After Upgrade
Once the upgrade process is completed, reboot your machine and check the version.
lsb_release -a
Output:
root@vps:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
Check OS-release
file
cat /etc/os-release
Output:
root@vps:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Done! Your server is now running Debian 12!