Upgrading Raspbian Pi from Bullseye (11) to Bookworm (12)
I run a couple of Raspberry Pis at home for various tasks — DNS servers (Unbound), Pi-hole, and similar utilities. They’ve been running stably for over two years, but they’ve remained on Bullseye for quite some time.
I generally prefer running one OS version behind the latest to avoid late-breaking fixes or regressions. Another advantage of staying a version behind is that I mostly receive security patches rather than potentially unstable new package updates. My hardware is also a bit dated — one is a Raspberry Pi 3 and the other a Pi Zero W — so I tend to be a bit cautious that way!
Still, it was finally time for an OS upgrade.
Most guides online suggested flashing a new SD card with the latest OS and spending a couple of hours reinstalling everything. I wasn’t keen on that approach — surely there had to be a proper way to upgrade Debian in place. Both Pis were headless and quietly doing their jobs, so I really didn’t want to attach a monitor or keyboard just for this. I was looking for the laziest possible way to perform the upgrade remotely.
sudo apt update && sudo apt full-upgrade
Step 2: Update sources.list
Now came the acid test: updating the sources.list to point to Bookworm.
In youir After that, I ran:
Preparing to unpack .../ncurses-term_6.4-4_all.deb ...
Unpacking ncurses-term (6.4-4) over (6.2+20201114-2+deb11u2) ...
dpkg: error processing archive /var/cache/apt/archives/ncurses-term_6.4-4_all.deb (--unpack):
unable to securely remove '/usr/share/terminfo/a/aaa.dpkg-new': Bad message
Errors were encountered while processing:
/var/cache/apt/archives/ncurses-term_6.4-4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
So I tried this
pi@raspberrypi:~ $ sudo apt clean
Followed by an attempt to fix any inconsistencies in the dpkg database.
pi@raspberrypi:~ $ sudo dpkg --configure -a
Then I attempted to fix my broken install
sudo apt --fix-broken install
Nope that didn’t cut it. Then I noticed that the real issue was the filesystem itself. The directory was “unreadable” as far as apt was concerned. So I went into the directory to check the status myself as root. Sure enough the file system was corrupted. So time to run fsck
I realised this has to be run during reboot. Unfortunately with systemd and the vast knowledge of stackoverflow said I have to modify the kernel startup parameter as such.
I tried to simply reboot hoping somewhere in there it would recognise a corrupt filesystem and reboot.
So I did sudo reboot
And Lo! And behold, it booted back up and file system is fixed.
Restarted the full upgrade again. It finished without any issues this time
Then I did the cleanup routine
sudo apt autoremove --purge -y
sudo apt clean
sudo reboot
And first thing I checked
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux
Yes. It is done
Now the internet advised me to check on all services and their status
pi@raspberrypi:~ $ sudo systemctl --failed
UNIT LOAD ACTIVE SUB DESCRIPTION
0 loaded units listed.
That seemed OK. Looks like the upgrade is a success! That was a major upgrade to a headless tiny box over the network! That is mighty impressive that Debian can handle such an upgrade without too many issues. Of course the disk corruption was a surprise that I didn’t anticipate.
My guess is everyone’s mileage may vary based on what they have installed and running. Mine was a simple PiHole and Unbound stock install with configuration that came through fine.