Introduction

Debian is one of the main forks, or distributions, of the Linux operating system. There are many derivatives of Debian Linux, like Ubuntu and Kali. Debian remains a popular and well-supported Linux operating system. As such, updates are released often.

This guide will walk you through upgrading Debian 8 (Jessie) to the next version, Debian 9 (Stretch).

How to Upgrade Debian 8 to 9 Linux Stretch

Prerequisites

  • A system with Debian 8 installed
  • Access to a Debian user account with sudo privileges (Alternately, access to a root user account if sudo is not installed)
  • Access to a command line/console window (CtrlAltF1)

Upgrade to Debian Version 9 Stretch

Step 1: Prepare To Upgrade

Upgrading to the current major version can be risky as it may destabilize your system. The following instructions will prepare it for a safe upgrade:

1. Upgrade the operating system in a test environment before rolling it out in a production environment.

2. Back up your data before running the upgrade.

3. Remove 3rd-party and outdated software repositories. Enter the following command into a console window to do so:

sudo aptitude search “~o”

Note: The default MySQL database application in Debian 8 has been replaced with MariaDB. Functionally, there is very little difference between MariaDB and MySQL. Plus, the upgrade process will convert your databases to the new format. However – the new database format is not backward-compatible with the older MySQL system yet. If your upgrade fails, you may need to import database files from a backup.


Step 2: Update Package Manager and Repositories

As with any software update or installation, it is highly recommended to update the local software lists. These steps ensure that your package manager is pointed at the latest and best-patched versions of the software. Also, they assure your installed software is at its most recent release, and therefore the most likely to be compatible after your upgrade.

1. To update the package repository, enter the following command in the terminal:

sudo apt-get update

2. Next, install software updates:

sudo apt-get upgrade

3. Finally, run any available operating system updates. In a console window, use the command:

sudo apt-get dist-upgrade

Step 3: Upgrade from Debian Jessie 8 to Debian 9

To upgrade to version 9 of Debian, you will need to edit the apt sources.list file.

1. In a console window, modify the sources file by entering:

sudo nano /etc/apt/sources.list

You should see a list of web addresses that list “jessie”.

2. Replace the content of this file with the following:

deb http://httpredir.debian.org/debian stretch main contrib non-free
deb http://httpredir.debian.org/debian stretch-updates main contrib non-free
deb http://security.debian.org stretch/updates main contrib non-free

The new file contents should refer to “stretch” instead of “jessie”. Save the file and exit.

3. Update the local software lists from the new repository lists:

sudo apt-get update

4. Next, install the base packages by running the following command:

sudo apt-get upgrade

5. Run the full operating system upgrade with the following:

sudo apt-get dist-upgrade

6. Debian 9 includes an upgrade to a newer version of the Linux kernel, and this process requires a reboot. If your system doesn’t restart as part of the upgrade, reboot your system manually from the console with: reboot

Step 4: Verify Debian Upgrade

Confirm or check successful upgrade by running the command:

cat /etc/os-release

The output should appear as:

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Step 5: Post-upgrade Cleanup

The apt package manager will do most of the cleanup work for you. You can finish removing packages that are no longer needed with the command:

sudo apt-get autoremove

Conclusion

Now you have Debian Jessie Linux upgraded to Debian Stretch on your server. With this tutorial, you should have a fully functioning and upgraded Debian 9 operating system.

After the upgrade, run the system through its paces by checking common system functions and frequently used applications.