Update Raspberry Pi to latest OS
It’s worthwhile to upgrade Raspberry Pi OS to have recent Python with system / GPIO libraries. These Python-tied libraries are not always easy to install otherwise. It is generally not worthwhile to upgrade the OS in place. Instead, copy off your files, do a fresh Debian install, and copy your files back. Keep the original SD card in case some setup is hard to figure out.
The best way to upgrade the Raspberry Pi operating system is get a new SD card and load the OS from scratch as described below.
Copy any wanted files from Raspberry Pi ~
home directory to your PC with sftp
or rsync
.
This is in case the original SD card fails.
Setup SD card: the contents of the SD card are erased in the following procedure. Buy a new SD card so that the original SD card remains with a working configuration in case there’s an issue.
Download Raspberry Pi OS Lite Image.
Write the OS image to SD card using Raspberry Pi Imager or the manual Linux-based process below.
Enable SSH by changing to the SD card boot
directory, and type
- Linux / WSL / MacOS:
touch ssh
- PowerShell:
New-Item ssh
Headless Raspberry Pi first boot: without a monitor and keyboard on the Pi, the Avahi dæmon on the Raspberry Pi will make it easy to find your Raspberry Pi when you plug into your LAN.
Note: changing the hostname
of your Raspberry Pi also changes the Avahi address correspondingly.
Put the SD card into the Pi, plug an Ethernet cord into your LAN router/switch and from your PC:
ssh pi@raspberrypi.local
Update Pi software
apt install rpi-update
rpi-update
apt update
apt upgrade
Raspberry Pi Configuration
raspi-config
Raspberry Pi reliable long-term install tips: avoid overclocking the Raspberry Pi for best long-term reliability. Use a heatsink kit for high-stakes remote operations.
Related: completely headless Raspberry Pi setup