Objective: To safely upgrade from Debian 8 (Jessie) to Debian 9 (Stretch) two servers and to keep good records of what was done to perform the upgrade.
- Server #1 is used just to verify and hold backups of other servers so it has no public services running.
- Server #2 hosts a diaspora*, a Hubzilla, a GNU social, a Friendica and a GNU Mediagoblin.
The definitive source on how to achieve the objectives
There are various tutorials with very brief instructions on how to go about the upgrade, but I decided to follow The definitive guide to upgrading from Debian Jessie (8) to Debian Stretch (9) at Debian.org to learn how to do the upgrade very carefully.
First off: I informed the users of the free social media instances about the upcoming upgrade and the downtime to be expected.
Make sure all the software are in their latest version
# apt update && apt upgrade
Made backups of
/var/www and the output of
dpkg --get-selections "*" and stored them off-site. Additionally I took a snapshot of the system disk just in case the upgrade doesn’t go well then it is possible to revert to the pre-upgrade situation.
Next checked for non-Jessie software with
$ apt-forktracer | sort
It found some items from jessie-backports but nothing that is in use.
Checked for half-installed packages with
# dpkg --audit
Nothing of interest was found. Just one dummy package.
Check for packages on hold
# dpkg --get-selections | grep 'hold$'
None were found.
Edit the /etc/apt/sources.list
Now update the /etc/apt/sources.list changing each occurrence of ‘jessie’ with ‘stretch’. I did it with sed (Stream EDitor) but it is also possible to manually edit the file with your favourite editor.
# sed -i 's/jessie/stretch/g' /etc/apt/sources.list
Start session recording for later reference
Next start session recording with (replace
step with a number. When needing to reboot then restart the session recording with an incremented number)
# script -t 2>~/upgrade-stretch
step.time -a ~/upgrade-stretch
If you have used the -t switch for script you can use the scriptreplay program to replay the whole session:
# scriptreplay ~/upgrade-stretch1.time ~/upgrade-stretch1.script
Update the package list with the Stretch sources in place
# apt-get update
Make sure you have enough disk space for the upgrade
# apt-get -o APT::Get::Trivial-Only=true dist-upgrade
There is ample of space so proceed with minimal upgrade (upgrading only the installed software).
# apt-get upgrade
Now time to upgrade the system. This will take a while.
# apt-get dist-upgrade
Next check if you have already installed the linux-image* meta-package
# dpkg -l "linux-image*" | grep ^ii | grep -i meta
If you do not see any output, then you will either need to install a new linux-image package by hand or install a linux-image metapackage. To see a list of available linux-image metapackages, run:
# apt-cache search linux-image- | grep -i meta | grep -v transition
If unsure which linux-image metapackage you can get longer description of the linux-image in question by running
# apt-cache show linux-image-amd64
Looks good. Let’s install it.
# apt-get install linux-image-amd64
apt-get reports that there are installed packages that are no longer needed. Remove them with
# apt-get autoremove
Now it is time to reboot for the new kernel to take effect.
Login and check the OS version
$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 9.5 (stretch) Release: 9.5 Codename: stretch
Verified that the services were up-and-running. Upgrade successful!
UPDATE: It seems there are 2 PostgreSQL running: Version 9.4 (the old one from Jessie) and Version 9.6, which ships with Stretch. Going to look into removing the old one safely.