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 to the 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.
Use the Raspberry Pi Imager to select Raspberry Pi OS Lite. BEFORE writing the OS image to SD card, enable SSH server and other desired options.
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 LAN or connect WiFi.
Put the SD card into the Pi, plug an Ethernet cord into the LAN router/switch and from the PC (username, hostname are those picked for the Pi by the Raspberry Pi Imager program):
ssh username@hostname.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