Updating Debian 11 to Debian 12 (Bookworm)

PowerADM.com / Linux / Debian / Updating Debian 11 to Debian 12 (Bookworm)

Before starting an in-place upgrade from Debian 11 to the new Debian 12 (Bookworm), we recommend backing up your operating system.

Check your Linux version:

# lsb_release -a

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

Check that the standard Debian Bullseye repositories are included in the list of apt repositories (/etc/apt/sources.list):

deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian-security/ bullseye-security main contrib non-free
deb-src http://deb.debian.org/debian-security/ bullseye-security main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free

If there are bullseye-backports or proposed-updates in the list of repos, disable them.

Debian 12: upgrading from Debian 11 Bullseye

Update all installed packages before upgrading Debian version:

# apt apt update
# apt apt upgrade -y
# apt apt autoremove -y

Find all packages not installed from official Debian repositories:

# apt list '?narrow(?installed, ?not(?origin(Debian)))'
# apt install apt-forktracer
# apt-forktracer | sort

Find and remove obsolete configuration files from previous updates:

# find /etc -name '*.dpkg-*' -o -name '*.ucf-*' -o -name '*.merge-error'

View the list of apt hold packages. It is recommended that you disable package hold before updating:

# cat /etc/apt/preferences
# cat /etc/apt/preferences.d/*

Check that all packages are allowed to be updated:

# dpkg --audit
# dpkg --get-selections | grep 'hold$'
# apt-mark showhold

The command returns packages that have been partially installed (Half-Installed), that have failed (Failed-Config), packages that have been set to Hold, and any packages with errors.

# apt-mark unhold package_name
# echo package_name install | dpkg --set-selections

Install the gpgv signature verification package:

# dpkg -l gpgv
# apt install gpgv

Replace the Bullseye repository with Bookworm:

# vim /etc/apt/sources.list

# From https://wiki.debian.org/SourcesList
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware

Update your package cache for the new Debian release:

# apt update

Check that you have enough disk space to download packages. This is how you can estimate the size of the update:

# apt -o APT::Get::Trivial-Only=true full-upgrade

New packages will be downloaded to /var/cache/apt/archives. There must be enough free space on the /var partition.

If necessary, you can find and delete large files and directories, or extend the size of the Linux partition.

The first step is to perform a minimal update:

# apt upgrade --without-new-pkgs

Then run the full update:

# apt full-upgrade

Reboot the server:

# systemctl reboot

Remove unnecessary files:

# apt-get autoremove

Search for deleted packages whose files are still on the hard disk:

# apt list '~c'
# dpkg -l | awk '/^rc/ { print $2 }'

Remove these files:

# apt purge '~c'
# apt purge $(dpkg -l | awk '/^rc/ { print $2 }')

Check your operating system version and make sure it has updated to Debian 12.0 Bookworm.

$ cat /etc/debian_version

12.0

Debian 12.0 Bookworm updata

Leave a Reply

Your email address will not be published. Required fields are marked *