Debian version 12, called Bookworm, was recently released. After only a few months of waiting, a version optimized for the Raspberry Pi was released, so it was time to upgrade. If I already did it for me, I'll write a step by step guide :)
The full changelog is here:
https://wiki.debian.org/NewInBookworm
If you write or run shell scripts, please consider the following:
- The "which" program has been deprecated, use command -v instead.
- /bin/sh is not longer supported (and use ksh instead, because it's faster).
- A syslog daemon, such as rsyslog, is no longer installed by default.
Follow the step-by-step instructions below and you will end up with a stable, clean and fresh Debian 12-based system for your Raspberry Pi. The whole process takes about 1 hour, including everything.
-
Check the current Debian version:
cat /etc/debian_version -
First make a backup. I usually use the "Win32 Disk Imager" software on Windows.
Don't miss this step. The guide has been tested and reviewed several times, but it's always better to be prepared for the unexpected. -
Open an SSH connection (PuTTY tricks here)
-
Be root with this command:
sudo su -
The upgrade process will take approximately 30 minutes. If you close the Terminal or lose connection during the upgrade process, errors will occur. To avoid this, start a screen and run the command in that session:
screen -R upgrade -
Update all packages:
apt update && apt upgrade -
Remove unnecessary packages:
apt --purge autoremove -
Configure new repositories by replacing bullseye with bookworm:
sed -i 's/bullseye/bookworm/g' /etc/apt/sources.listThis command may fail, it's okay:
sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/* -
Check for new packages:
apt update -
Upgrade only existing packages on the system:
apt upgrade --without-new-pkgs -y -
Press 'q' when you see the ":" as a prompt. It's just a manual.
-
During the upgrade process, follow the on-screen instructions carefully, as you may be asked a few questions during the process, such as “Would you like to restart the service?” or “Keep or erase configuration file options?” throughout the process.
If you don't know what is the right answer, I'd recommend just press "Enter" to select the default one. -
And now the final upgrade:
apt full-upgrade -y -
Reboot the system:
reboot -
Check the Debian version now:
cat /etc/debian_version -
Remove old and unused packages:
apt --purge autoremove -
If you have shell scripts, don't forget to check them based on these:
- Replace "which" with command -v
- Replace /bin/sh with /bin/bash, or with /bin/ksh
- syslog is not installed by default, you may need to replace the corresponding commands (like rsyslog) -
That's it, we're done.
Source: https://feriman.com/upgrading-raspberry-pi-os-from-bullseye-to-bookworm-11-to-12/
Tested on five raspberry pi 4