Site Overlay

Upgrading Raspbian from Stretch to Buster

With the new Buster release for the Raspberry Pi being out for some weeks, it’s time to upgrade my Pi Zero W server. Unfortunately, though, this is not so easy as a dist upgrade on some major distro like Ubuntu. The official recommendation is to start with a fresh image and then copy over the user-specific settings over from the former production system. – Easier said than done! As other users point out, transferring and adapting config files for apache, php-fpm, Nextcloud, WordPress, Prosody, Asterisk, Mysql,…. will take days to complete. Fortunately, PiMyLifeUp describes a more convient way to upgrade from Stretch to Buster.

1. Precautions to be taken against fatal loss of production system

  • Produce a full backup of your stretch production system. Using raspiBackup is recommended.
  • Take an empty microSD card and restore a clone of the production system to that card. That also ensures that the backup of your production is actually restorable in case of need. Writing the restore took about 3 hours for my system. Different microSD card sizes for the production and the clone are allowed as long as the space on the clone card is sufficient to hold all data from the production system.
  • Disconnect the production system, boot up the clone and perform any of the subsequent steps on the clone.

2. Basic upgrade procedure

You can perform the upgrade on any Raspberry Pi device. There is no problem if you lateron take that SD card and plug in in your Zero W production device. My recommendation is to run the upgrade on the most performant Raspberry in your inventory (in my case that’s a 3B+). Doing so will not only speed up the upgrade process but also prevent that you get stuck in the upgrade process for insufficient memory.

My system was once wrecked when the upgrade got stuck at “Generating Locales” because the Pi Zero W had run out of memory.

[alert type=”warning” icon-size=”normal”]In any case you should run sudo raspi-config to disable the camera and set the GPU memory to the minimum of 16 MB for the update. Do not forget to reboot the clone to ensure that the settings take effect.[/alert]

Then follow the instructions on PiMyLifeUp. Make sure at the end, that you reinstall apt-listcache. When asked if services shall be restarted without confirmation choose yes. For any config files choose the option to go with the current ones (“N” or “O”).

3. PHP 7.3

3.1 Install missing PHP 7.3 modules

The upgrade will only produce a bare bone PHP 7.3 installation and assumes that you are going to stick with your version 7.0 PHP. But getting PHP 7.3 support is one of the major advantages of switching from Stretch to buster. We therefore have to install some modules manually. The following list is taken from an article on As we use MariaDB we have omitted PostgreSQL. Several of the listed modules will already be installed, and I am not sure if the redis related modules are really necessary. Modules already installed will be skipped by apt and there’s no real harm in installing modules that are not needed.

3.2 Amend configuration files for PHP 7.3

Edit /etc/php/7.3/fpm/pool.d/www.conf as follows:

Most important is the need to set the listen address to:

Uncomment the following lines by removing the leading semicolon:

Further amends of the 7.3 configuration may be needed. I recommend comparing the new /etc/php/7.3/fpm/pool.d/www.conf file against the old /etc/php/7.0/fpm/pool.d/www.conf file on a desktop machine with some software like Meld to check for differences.

3.3 Activate PHP7.3 FPM

4. WordPress

While Nextcloud should be ready to go, WordPress still has trouble with the crayon syntax highlighter module. My recommendation is to deactivate the module.

5. Prosody

Prosody will have troubles finding the certificates. The only way which is really working safely for now is to acquire root privileges and copy copy the most recent certX.pem and privkeyX.pem from /etc/letsencrypt/archive/ to /etcprosody/certs and rename them to localhost.key and localhost.crt.
Any other approach has so far failed because the certificates are both used by nginx and prosody. Symlinks apparently cannot cope with that ownwership structure.

6. Python modules

I later found out that a couple of Python scripts did not work because some of the modules they import got lost during the upgrade from Stretch to Buster. Therefore they should be manually reinstalled via pip. This is also a good opportunity to make sure that pip is in the most recent version: