Skip to content

Instantly share code, notes, and snippets.

@Iksas
Last active February 2, 2025 22:41
Show Gist options
  • Save Iksas/af970b7a67339612bb316f8042581d72 to your computer and use it in GitHub Desktop.
Save Iksas/af970b7a67339612bb316f8042581d72 to your computer and use it in GitHub Desktop.
Raspberry Pi: Remote upgrade from Buster to Bullseye (via WiFi)

Buster >> Bullseye - Remote upgrade

These instructions can be used to upgrade Raspberry Pi OS from Buster to Bullseye with only an SSH connection (no physical access). Some addidional steps are performed to make sure that the Pi automatically joins the WiFi network after upgrading. This is necessary if the Pi is located in a remote or hard to reach location.

Especially on older Pis, the upgrade will take several hours, so plan accordingly.

If you have physical access to the Pi, consider making a backup of the SD card with the SD Card Copier utility (red berry menu in the top left >> Accessories >> SD Card Copier). If the SD Card Copier is not in the menu, you can install it with sudo apt install piclone.

The upgrade process

  1. Make sure Buster is as up to date as possible:

    • sudo apt update
    • sudo apt full-upgrade
  2. (optional) If you use manually installed Python packages, you can export a list of them, allowing you to quickly reinstall them after upgrading:

    • Python 2: pip freeze > python_2_packages.txt
    • Python 3: pip3 freeze > python_3_packages.txt
  3. IMPORTANT: Prevent the connman package from being installed. This package is not needed and prevents the system from automatically connecting to the WiFi after the first reboot:

    • sudo apt-mark hold connman
  4. Change the package sources to Bullseye:

    • sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list
    • sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/raspi.list
  5. Update the package sources and upgrade to Bullseye:

    • sudo apt update
    • sudo apt install libgcc-8-dev gcc-8-base
      • After some time, a message titled apt-listchanges: News will pop up. You can close it with q.
      • When asked if services can automatically be restarted, use your arrow keys to select Yes and confirm with the return key.
      • When asked about changed configuration files, choose Y if you didn't manually change the file. For manually changed files, choose N. To see the changes in the file, choose D, use the arrow keys to scroll the diff list and close it with q.
    • sudo apt full-upgrade
      • Follow the same steps as for the last command.
  6. Remove old packages:

    • sudo apt autoremove
  7. Switch to the new GPU driver on the Raspberry Pi 4:

    • sudo sed -i 's/vc4-fkms-v3d/vc4-kms-v3d/g' /boot/config.txt
  8. (optional) If you exported your Python packages in the previous steps, you can reinstall them now:

    • If you want to install the latest version of all Python packages (instead of the one that was previously installed), you can run these commands first:
      • Python 2: sudo sed -i 's/==/>=/g' python_2_packages.txt
      • Python 2: sudo sed -i 's/==/>=/g' python_3_packages.txt
    • Install the Python packets:
      • Python 2: sudo pip install -r python_2_packages.txt --upgrade
      • Python 3: sudo pip3 install -r python_3_packages.txt --upgrade
        • Note that if pip/pip3 fails to install a package, all subsequent packets will be skipped. If this happens, fix the error and re-run the command.
  9. IMPORTANT: The upgrade deleted the WiFi country setting. You have to set up your WiFi country, or the WiFi will be disabled after rebooting:

    • sudo raspi-config
      • Go to 5 Localisation Options >> L4 WLAN Country and choose your country.
  10. Finally reboot the system:

    • sudo reboot
@Iksas
Copy link
Author

Iksas commented Jul 28, 2024

Hi @benwebbbenwebb, I'm glad you found this helpful!

Also thanks for your additions. It's pretty strange that sudo apt-mark hold connman had no effect on your machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment