This post is part of the Adventures with a Raspberry Pi series.
Upgrading the OS on a raspberry Pi is recommended to be done one version at a time. Once you know exactly which version of Raspbian (or Raspberry Pi OS as newer versions are known), you will be able to determine the upgrade path you need to follow. I covered how to determine which OS version you have in the previous post in this series.
There is a version history page available on Wikipedia which shows the versions of the OS and the Raspberry Pi hardware on which it is supported. In my case I have a Raspberry Pi 3B+ which is running Raspbian 9 (Stretch) which means I have two upgrades of the OS to perform to get to the latest version.
There are several steps to go through to upgrade the OS. First we need to edit the sources.list file to update the distribution to which the Raspberry Pi is to be upgraded. Open this file by running the following command on the PI:
sudo nano /etc/apt/sources.list
This will launch the editor:
To upgrade the stretch distribution to the next one, I need to change the word stretch on the first line to buster and then hit Ctrl+X
:
Type Y
and hit return to save the change:
When prompted for the filename, just hit return to save the file with the original name:
Back at the command prompt we can now run a command to download the distribution named in the sources.list file which we just edited:
sudo apt update
Once the command finishes running you’ll be given a report of what has been downloaded:
The next step, and the one which takes the most time, is run the command to perform the upgrade using the downloaded distribution:
sudo apt upgrade
When you run this command there could be a number of prompts which you need to respond to.
The first of these prompts was to confirm the upgrade:
The change log will automatically open, but you can hit q
to exit:
You’ll be prompted to make a decision on Samba:
The next question I got was as to whether services should be automatically restarted or not; I opted to do so as the only thing I run on this computer is Pi-hole:
The final question was on whether to upgrade lighttpd or upgrade it:
Once the upgrade is complete you’ll be dropped back to the command prompt:
It is recommended that you restart the computer once the installation is complete which can be done using the following command:
sudo reboot
If, like me, you are two versions behind, you will need to perform the above again changing buster
to bullseye
in the sources.list and then repeat all of the steps.
Adventures With A Raspberry Pi
What should we write about next?
If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.