Update Raspberry Pi to Debian/Raspbian Stretch 9

Related: Full headless Raspberry Pi setup

Why upgrade Raspberry Pi to Debian/Raspbian Stretch 9

It’s worthwhile to upgrade to Debian Stretch 9, to go from system Python 3.4 to 3.5, get QT5, etc. I found it was not worthwhile to upgrade Raspbian in place, as it took several hours and filled my 8 GB SD card. The best way to upgrade the Raspberry Pi operating system is to wipe (erase) the SD card and reload with Debian/Raspbian from scratch as described below.

  1. copy any wanted files from Raspberry Pi ~ home directory to your PC with sftp or rsync. The contents of your SD card are erased in the following procedure.
  2. Download Raspbian Image
   wget https://downloads.raspberrypi.org/raspbian_lite_latest
  1. Write Raspbian image to SD card: before and after inserting the SD card into your PC, type
  1. Assuming the SD card was at /dev/mmcblk0 (use lsblk to find SD card mount point):
   unzip -p *raspbian*lite* | sudo dd of=/dev/mmcblk0 bs=4M status=progress conv=fsync

The option conv=fsync prevents dd from instantly saying it’s done, helping avoid mistakenly removing the SD card before it’s done writing. 5. This will take 5-10 minutes depending on your SD card speed.


ensures the writing has completed. 6. Enable SSH by changing to the SD card boot directory, and type

   touch ssh
  1. eject the SD card from your PC.

Headless Raspberry Pi first boot

You don’t need a monitor and keyboard, 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.

  1. Put the SD card into the Pi, plug an Ethernet cord into your LAN router/switch and from your PC:
   ssh pi@raspberrypi.local
  1. Update Pi software
   apt install rpi-update
   apt update
   apt upgrade
  1. Raspberry Pi Configuration

Raspberry Pi reliable long-term install tips

  • avoid overclocking beyond one step above minimum.
  • Use heatsink kit for high-stakes remote operations.