If you are reading this article, this implies you are facing big trouble when upgrading Raspberry pi OS from buster to bullseye.
Make sure you have a cloned backup of your Raspbian OS, as some commands in this guide are irreversible. Even if none of the following steps works, you can fall back to the previous state of Raspbian with your cloned Raspberry pi copy. You can look at my earlier article about how to create a cloned backup with a new SD card via DiskGenius.
Situation 1: Only a blinking line/cursor after reboot. The GUI interface does not work on my Raspberry pi 4.
There is a high chance that your GUI dependency was removed accidentally during the upgrade. You may need to install them back manually.
Step 1: Connect your Raspberry pi to a monitor. Try to enter “Ctrl + Alt + F1” and see if a CLI interface appears. If yes, you may type “startx” to enter the GUI. If it said
Error 1 .Xauthority does not exist
try to fix it by
sudo touch ~/.Xauthority
If it said
Fatal server error:
Server is already active for display 0
If this server is no longer running, remove /tmp/.X0-lock
try to fix it by
sudo rm /tmp/.X0-lock
If the “Ctrl + Alt + F1” command does not work, try to access your Raspberry pi through SSH / TeamViewer / AnyDesk. Follow step 2 if you can remote access your Raspberry pi.
Step 2: Check the status of Lightdm
sudo systemctl status lightdm
If it shows
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
or something like “error (exit)” Try to fix it by
sudo apt install accountsservice -y
sudo apt install pipanel -y
sudo apt-get install raspberrypi-ui-mods -y
Step 3: Check whether your Xorg, Xauth, and Openbox packages exist
sudo apt list xorg
sudo apt list xauth
sudo apt list openbox
If not, install it again by
sudo apt-get install xorg
sudo apt-get install xauth
sudo apt-get install openbox
Reboot your system to take effect. If it still does not work, move to step 4.
Step 4: If Lightdm starts before the graphical driver is loaded, the GUI will not show correctly.
Edit the configuration file of Lightdm by
sudo nano /etc/lightdm/lightdm.conf
Change
logind-check-graphical=false
to
logind-check-graphical=true
under the [LightDM] session.
Again, restart your system to take effect. If it still does not work, move to step 5.
Step 5: Check whether dispsetup.sh exists. If it returns something, skip this step and move to step 6.
If not, create dispsetup.sh manually
sudo cat /usr/share/dispsetup.sh
#!/bin/sh
if ! grep -q 'Raspberry Pi' /proc/device-tree/model || (grep -q okay /proc/device-tree/soc/v3d@7ec00000/status 2> /dev/null || grep -q okay /proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null || grep -q okay /proc/device-tree/v3dbus/v3d@7ec04000/status 2> /dev/null) ; then
if xrandr --output HDMI-1 --primary --mode 1920x1080 --rate 60.00 --pos 0x0 --rotate normal --dryrun ; then
xrandr --output HDMI-1 --primary --mode 1920x1080 --rate 60.00 --pos 0x0 --rotate normal
fi
fi
if [ -e /usr/share/tssetup.sh ] ; then
. /usr/share/tssetup.sh
fi
exit 0
Change its permission
sudo chmod 755 /usr/share/dispsetup.sh
Reboot to take effect. If it still does not work, follows step 6.
Step 6: Check for any version mismatch on the Lxplug module. Also, verify whether the Bluetooth module exists.
apt list *lxplug*
apt list pulse*
dpkg -l | grep lxpanel
ii lxplug-bluetooth armhf Bluetooth plugin for lxpanel
means the Bluetooth module exists. If you find any mismatch/missing module, you will need to rebuild it manually.
sudo apt build-dep <package-name>
Or follow the instruction in this guide.
Restart to take effect. If it still does not work, follow step 7.
Step 7: You may change the crucial files or directories ownership under /home/pi to other users. You may change it back by
sudo chown -R pi:pi /home/pi
This step will likely not bring your GUI back after reboot. Follow step 8.
Step 8: Change the screen mode from fkms to kms.
sudo nano /boot/config.txt
dtoverlay=vc4-kms-v3d
start_x = 1
Press Ctrl + X to save the file Reboot to take effect.
Situation 2: My taskbar icon and settings were restored to the default Debian icon. Try to fix it by installing the Raspberry pi UI packages.
sudo apt install accountsservice -y
sudo apt install pipanel -y
sudo apt-get install raspberrypi-ui-mods -y
Situation 3: My Bluetooth module on the taskbar disappeared after the upgrade. Verify whether the Bluetooth module exists.
apt list *lxplug*
apt list pulse*
dpkg -l | grep lxpanel
ii lxplug-bluetooth armhf Bluetooth plugin for lxpanel
means the Bluetooth module exists. If you find any mismatch/missing module, you will need to rebuild it manually.
sudo apt build-dep <package-name>
Or follow the instruction in this guide.
If none of the following steps works, you can fall back to the previous state of Raspbian with your cloned Raspberry pi copy. :'(
If the above steps bring back your GUI, I still recommend you migrate your data to a clean Raspbian Bullseye.
There is a high chance of missing packages other than your system’s GUI packages.