Adventures With A Raspberry Pi: How to Update the OS on a Raspberry Pi

Raspberry PiThis 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:

sources.list in 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:

sources.list in editor with distribution changed

Type Y and hit return to save the change:

Confirm modified file should be saved

When prompted for the filename, just hit return to save the file with the original name:

Confirm the filename

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:

Result of sudo apt update

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:

Confirm upgrade

The change log will automatically open, but you can hit q to exit:

Change log of Raspbian

You’ll be prompted to make a decision on Samba:

Samba decision

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:

Confirm restart of services

The final question was on whether to upgrade lighttpd or upgrade it:

lighttpd question

Once the upgrade is complete you’ll be dropped back to the command prompt:

Upgrade complete

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

Adventures With A Raspberry Pi
Building The Raspberry Pi: CanaKit Raspberry Pi 3 B+ Complete Starter Kit
Building The Raspberry Pi: Raspberry Pi Build
Building The Raspberry Pi: Install Operating System
Building The Raspberry Pi: First Run
Building The Raspberry Pi: System Configuration Tool
Building The Raspberry Pi: Enable SSH For Remote Access
Building The Raspberry Pi: Securing the Raspberry Pi
Building The Raspberry Pi: Conclusion
Installing Pi-hole On A Raspberry Pi: What is Pi-hole?
Installing Pi-hole On A Raspberry Pi: Install Pi-hole
Installing Pi-hole On A Raspberry Pi: Change Pi-hole Admin Password
Installing Pi-hole On A Raspberry Pi: Configure Network to use Pi-hole
Using Pi-hole On A Raspberry Pi: Blocked Adverts
Using Pi-hole On A Raspberry Pi: Admin Interface
Using Pi-hole On A Raspberry Pi: Disabling Pi-hole
Using Pi-hole On A Raspberry Pi: Whitelisting a Site
Using Pi-hole On A Raspberry Pi: Update Blocklists
Using Pi-hole On A Raspberry Pi: Maintain Blocklists
Using Pi-hole On A Raspberry Pi: Change DNS Servers
Using Pi-hole On A Raspberry Pi: Connecting With SSH
Using Pi-hole On A Raspberry Pi: Updating the Pi-hole
Using Pi-hole On A Raspberry Pi: Conclusion
What Else Can I Use It For?
Prepare New SD Card For Raspberry Pi OS: Download SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Install SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Format SD Card
Prepare New SD Card For Raspberry Pi OS: Download NOOBS
Prepare New SD Card For Raspberry Pi OS: Copy Files To The SD Card
Prepare New SD Card For Raspberry Pi OS: Conclusion
Installing Pi-hole On A Raspberry Pi: Changing the IP Address
Raspberry PI Update Fails
Check Version of OS on Raspberry Pi
How to Update the OS on 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.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

Your email address will not be published. Required fields are marked *