archive2019

Moving headless Pis to Raspbian Buster with a fresh install

Raspbian Buster came out together with the Raspberry Pi 4. The Raspberry Pi team does not recommend upgrading from Stretch. How I plan to move headless Pis to a fresh image.

2 min read#edge#raspberry-pi#linux

Raspbian Buster was released this week, together with the Raspberry Pi 4. It is based on Debian 10 “Buster”, and it is the only Raspbian that supports the Pi 4. It runs on the older boards too.

The announcement is clear: they do not recommend upgrading an existing Stretch system to Buster. It is possible, but they cannot say what will break. So for my headless Pis I will flash new cards and move the config over, one Pi at a time.

Before flashing

I make a list from the old card first. This is the part I always forget something in.

# packages I installed by hand
apt-mark showmanual > ~/manual-packages.txt

# my own services and timers
ls /etc/systemd/system/*.service

# cron
crontab -l > ~/crontab.txt
sudo crontab -l > ~/root-crontab.txt 2>/dev/null

# pip packages installed outside a virtualenv
pip3 freeze > ~/pip3-freeze.txt

Then I copy these files, /etc/mosquitto, /etc/telegraf and my scripts to another machine with rsync. I keep the old SD card unchanged in a drawer for a few weeks.

Headless setup on the new card

Same as before. After flashing, put an empty file named ssh and a wpa_supplicant.conf in the boot partition:

touch /media/$USER/boot/ssh
cp wpa_supplicant.conf /media/$USER/boot/

On first login: change the password, set the hostname, run sudo apt update && sudo apt full-upgrade.

For a Pi 4 without a monitor, the announcement suggests switching from the new GL graphics driver to the legacy driver in raspi-config. I have not seen a reason for it yet on my side, but I follow it on headless boards since I do not need the GL driver there.

Things to check after the move

  • Python. python3 is now 3.7 (on Stretch it was 3.5). python is still Python 2.7. Scripts with #!/usr/bin/env python keep running on Python 2, which has only six months of support left. I want to fix those shebangs anyway.
  • Packages that were installed with pip3 outside a virtualenv must be reinstalled, because they were built for the old Python.
  • Packages from third-party apt repositories. Check that the repository has a buster release before you add it. Some may only have stretch for now.
  • If you moved the card from an older Pi to a Pi 4, it will not boot. The Pi 4 needs Buster.

The announcement also mentions a few desktop packages that are not ready yet for Buster. I only use Lite on these boards, so I did not check them.