Debian is a very reliable OS for servers, though you can install it on desktops too.
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.
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 /etc, /var/lib/dpkg, /var/lib/apt/extended_states/home/username, /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-stretchstep.time -a ~/upgrade-stretchstep.script
If you have used the -t switch for script you can use the scriptreplay program to replay the whole session:
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:
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.
# reboot
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.