Upgrading Debian GNU/Linux from Jessie to Stretch

The official Debian GNU/Linux logo
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.

  1. Server #1 is used just to verify and hold backups of other servers so it has no public services running.
  2. 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.

Preparation

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:

# scriptreplay ~/upgrade-stretch1.time ~/upgrade-stretch1.script

The upgrade

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.

# 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.

Upgrading MediaWiki

This method is discouraged. Use the latest tarball instead unless good reason to run the live code tree

Objective: Get the freshest MediaWiki installed on http://develop.consumerium.org/wiki/ using git where ever possible.

Instructions followed: The official upgrading MediaWiki guide

Thanks go to: Naturally the MediaWiki devels and documenters. Special thanks to SPF|Cloud @ freenode irc for kind help in figuring out the problems encountered

MediaWiki - Because ideas want to be free.
MediaWiki logo is public domain by User:Anthere

I upgraded from 1.25.6 to 1.28 alpha which is the in-development version. My experience with MediaWiki is that the people responsible for the tech know what they are doing. Prestige software attracts prestige devels so I decided to go with the development version.


First off: Backup the files and the database. Something could go wrong even if usually MediaWiki upgrade procedures are rock-solid.

Then get the latest MediaWiki from git with

git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git

Next get all the skins by removing the skins directory and then issuing in the MediaWiki core directory

git clone --recursive https://github.com/wikimedia/mediawiki-skins skins

Change into the extensions directory and update the extensions with

git pull

Put the images/ and the extensions/ directory into a .tar.gz and move it over to the ../core/ directory and uncompress there

Get the vendor libraries used by WMF clusters

git clone https://gerrit.wikimedia.org/r/p/mediawiki/vendor.git

Now you are ready to do the upgrade. I shut the Apache2 down for the duration of that just to feel more secure that the update.php will work but I don’t think this is required for safety. Change to the maintenance/-directory in core/ and

php5 update.php

move the old w/-directory out of the way and move core/ into w/ and access the Special:Version of your wiki in browser and you should see that it is up and running with the latest software version.


And keep up-to-date

  • ‘git pull’
  • ‘git pull –recurse-submodules’ in skins/ and extension/
  • Got some complains about composer being out-of-date. Fix with ‘sudo composer self-update’ and ‘composer update’
  • ‘php maintenance/update.php’