The Raspberry pi foundation released Raspbian Bullseye in Nov 2021, and Raspbian buster became obsolete. You should update your raspberry pi from buster to bullseye in order to get the latest security updates and software patches.
The Raspberry pi foundation recommends having a clean install of Raspbian bullseye from a new drive instead of upgrading it from buster. I agree because it cost me a total of 6 copies of cloned Raspberry pi backup in order to upgrade to Raspbian bullseye successfully.
If you insist on upgrading your raspberry pi from buster to bullseye, here are the things you have to take care of:
1. Make sure you have a cloned backup of your Raspbian OS. You can look at my previous article about how to create a cloned backup via DiskGenius.
2. Ensure you can SSH to your Raspberry pi. The GUI may not work after the update. You may need SSH for troubleshooting. Having another remote software such as TeamViewer or AnyDesk as a backup plan is a plus.
3. Your Raspberry pi should connect to a LAN interface. The wireless interface may reset after upgrading to Raspbian bullseye. Having physical access to your Raspberry pi is recommended.
I only tested the following guide on a Raspberry pi 4. It may not work for other Raspberry pi. Again, you must have a cloned backup before executing any commands on this guide, as the commands you enter are irreversible.
Step 1: Update the package list and install the required packages
sudo apt update
Step 2: Update your system packages to the latest buster version and remove the old packages.
sudo apt dist-upgrade -y
Step 3: Update the Raspberry pi source list
sudo nano /etc/apt/sources.list
change
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
to
deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
Press Ctrl + X to save the file.
Performing the same thing to raspi.list if it exists.
sudo nano /etc/apt/sources.list.d/raspi.list
Step 4: Update your system packages to the latest bullseye version and remove the old packages.
sudo apt dist-upgrade -y
Step 5: During the update, you may encounter an error like this
The following packages have unmet dependencies:
libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.3.0-6+rpi1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
Enter
sudo apt install gcc-8-base -y
then
sudo apt dist-upgrade -y
to continue the installation.
Press q to stop reading the changelogs.
Later on, you will face an error like this.
got an old version of npm installed, possibly because you installed it manually
Errors were encountered while processing:
nodered
Preparing to unpack .../150-nodered_2.2.3-2_armhf.deb ...
dpkg: error processing archive /tmp/apt-dpkg-install-CujUtn/150-nodered_2.2.3-2_armhf.deb (--unpack):
new nodered package pre-installation script subprocess returned error exit status 5
Errors were encountered while processing:
/tmp/apt-dpkg-install-CujUtn/150-nodered_2.2.3-2_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Luckily I can read german, and I found the solution through a german article by Georg Keller.
I have made a small modification to his solution. The option “–node12” will ensure the script function correctly.
sudo apt-get remove nodered
sudo apt-get autoremove
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node12
Continue the update after the troubleshooting.
sudo apt dist-upgrade -y
Step 6: It seems everything is fine as you can execute the “sudo apt dist-upgrade -y” till the end, but it’s not. Check the status of your lightdm service by
sudo systemctl status lightdm
You will find something like
:active (running)
Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files
To fix it, you must install the Pipanel and related packages again.
sudo apt install accountsservice -y
sudo apt install pipanel -y
sudo apt-get install raspberrypi-ui-mods -y
Step 7: Reboot the system to take effect. You may encounter errors like
invalid menu directory 'system/lxterminal.desktop'
or
invalid menu directory 'Accessories/pcmanfm.desktop
when you click the folder or terminal icon on the taskbar. It can be fixed by rebooting your Raspberry pi again.
Step 8: Check your Raspberry pi OS version by
lsb_release -a
Optional: Update Raspberry pi firmware to reduce the risk of vulnerabilities being exploited.
sudo rpi-update
Congratulation if your Raspbian GUI works appropriately. If not, you have some missing packages on your Raspbian buster system that are required for the Raspbian bullseye system. You should migrate your data from your cloned backup to a clean Raspbian bullseye system.
If you followed some dated guide and failed to update to Raspbian bullseye, read my troubleshooting guide.