This post will teach you how to perform software updates and firmware updates on a Rasberry pi board running Raspberry Pi OS. Before getting started, let’s answer one common question – What is the need for applying updates and upgrades to our Software and devices?
There are two main reasons:
Every program running on your Raspberry PI board is just but a bunch of code. From hundreds to millions of lines of code. Unfortunately, some sections of this code can expose various vulnerabilities, commonly known as CVEs (Common Vulnerabilities and Exposures). These CVEs are made publicly available to everyone on the internet and in various hacker forums. To give you a little more insight, check out this KODI CVE recently exposed. To mitigate this and more related security issues, we need to perform regular software updates on our devices.
Other than security, some updates are necessary to boost the overall performance. When certain software is lagging and even taking time to launch, you should really try applying updates and see the difference. Some updates can also be long-term. A good example is the Linux XFS Patch for the Year 2038 Problem.
With that information, we can now dive in and update our Raspberry Pi.
- A Raspberry Pi installed with Raspberry Pi OS
- A backup of your important files in case something goes wrong during the update
- Sudo access
- A reliable power supply
- A reliable and active internet connection
You can check out our master guide post on How to Install the official Raspberry Pi OS.
Update Raspberry Pi OS
Since the official Raspberry Pi OS is based on Debian, we can easily use the APT package manager to install our updates. Execute the command below to update the repository package list:
sudo apt update
Once the execution completes, we can proceed to update all the installed packages to their latest versions.
Tip: An upgrade will download all the necessary files required for your packages. At times, it can be big compared to the available space on your Raspberry PI SD card. To avoid such issues, you can use the
df -h command to see the available space. Luckily, the upgrade tool will tell you how much space will be required.
Execute the command below to perform a full upgrade:
sudo apt full-upgrade
apt full-upgrade performs a similar action to the
apt distro-up. However, it doesn’t upgrade your Raspberry OS from one release to another. It only ensures the installed packages and the OS are up to date.
.deb files might be downloaded during the upgrade process and are no longer necessary once the installation completes. Normally they are stored in the
/var/cache/apt/ archives directory. To remove them and create more space in your system, execute the command below:
sudo apt clean
Once done, reboot your device to apply the necessary system configurations.
sudo reboot now
Update the Raspberry Pi Firmware
The Raspberry foundation is responsible for developing Raspberry Pi boards, Raspberry Pi OS, and the firmware it runs. Once in a while, a new firmware update is made to handle security or performance issues. Updating the firmware is different from software updates explained above using the
apt update command.
To update the firmware, we will use the
rpi-update tool. Execute the commands below one by one.
sudo apt update && sudo apt install rpi-update sudo rpi-update
Once done, reboot the Pi.
Upgrade from Stretch to Buster
Note: Upgrading from one version of the Raspberry Pi OS is possible, but it comes with its own risks. You can easily lose your data or corrupt your current install. I highly recommend you consider downloading the latest image and install using the method described in this post.
To upgrade from Raspberry Stretch to Buster, we first need to modify the
sources.list file. Execute the command below:
sudo nano /etc/apt/sources.list
Replace every single stretch word with buster. When done, do the same to
raspi.list file. Execute the command below to open it with the nano editor.
sudo nano /etc/apt/sources.list.d/raspi.list
When done, save the file (Ctrl + O, then Enter) and Exit (Ctrl + X). Now install the updates with the commands below:
sudo apt update sudo apt -y dist-upgrade
In case of any prompts, type YES and hit Enter. There are instances where a window will open displaying a piece of information. Use the space key to scroll to the bottom and press q to continue with the installation. When done, reboot your Pi.
Now that you know how to update your Raspberry Pi, why not try exiting stuff like Overclocking your Pi for better performance or even set it up as a Network Attached Storage. Feel free to share more Raspberry Pi tips with our readers in the comments below or ask any questions, and we will answer as soon as possible.