FactorPad
Build a Better Process

How to Upgrade to Debian Stretch 9 from Jessie 8

Many Linux system administrators put off a major release upgrade of their server fearing what could go wrong. Here we see how easy it can be.
  1. What's new? - Review what's new and exciting about Debian 9.
  2. Debian 8 - Perform seven preliminary actions on the Debian 8 Jessie system.
  3. Upgrade to 9 - Kick off the distribution upgrade to Debian 9 Stretch.
  4. Suggestions - Find suggested readings at debian.org.
  5. Verify - Ensure that the OS upgrade was successful.
face pic by Paul Alan Davis, CFA
Updated: February 23, 2021
An in-place upgrade doesn't have to be daunting. Just follow the steps below.

Outline Back Tip Next

/ factorpad.com / tech / linux / tutorial / upgrade-to-debian-stretch.html


An ad-free and cookie-free website.


An In-Place Upgrade to Debian 9 Stretch

Intermediate

Learn to upgrade your Debian-based Linux operating system with step-by-step instructions in both video and text.

Video Tutorial

Videos can also be accessed from our Linux Tutorials for Debian-based Distros Playlist on YouTube.

How to Upgrade to Debian Stretch 9 from Jessie 8 | Linux Tutorial (15:03)

Video Transcript with Code Examples

Welcome. Today's task is to perform an in-place upgrade of a Debian 8 Jessie Linux operating system to Debian 9 Stretch.

I'm Paul, and if you're like me, before today you feared upgrading a Linux server packed with years worth of data, code and working programs knowing full-well that the end-of-life date for Jessie has come and gone.

So here we tackle the upgrade in 5 steps with what's new in Stretch, followed by several commands on the Debian Jessie 8 side before kicking off the upgrade to version 9 followed by suggested readings at debian.org before verifying that everything went as planned.

If you would like to follow along and see all of the commands in print the first link in the video's Description goes to a web page with the full transcript from the video and all of the code plus helpful links.

Step 1 - Review What's New and Exciting About Debian 9

Let's start with Step 1 and cover what's new in Debian 9.

a. What comes with the Debian 9 upgrade?

So what's exciting about the Debian 9 upgrade beyond two more years worth of security patches Debian contributors so kindly take care of behind the scenes for us?

If you recall, major releases of Stable versions are made every two years, so doing this in-place upgrade isn't something we can ignore for too long.

Plus, this new release means that many of the popular packages in the Stable repository bump up to new versions as well. Let's have a look at some of those.

paul@fullstack:~$ less notes/debian/upgrade-to-debian-stretch.txt
Version Changes between Debian 8 Jessie and Debian 9 Stretch Package Jessie 8 Stretch 9 ------------------------- -------- --------- BIND DNS Server 9.9 9.10 Emacs 24.4 24.5 and 25.1 Exim default email server 4.84 4.88 GNU Compiler Collection 4.9 6.3 GnuPG 1.4 2.1 Inkscape 0.48 0.91 GNU C library 2.19 2.24 Linux kernel image 3.16 4.9 MariaDB 10.0 10.1 Nginx 1.6 1.10 OpenJDK 7 8 OpenSSH 6.7p1 7.4p1 Perl 5.20 5.24 PHP 5.6 7.0 Postfix MTA 2.11 3.1 PostgreSQL 9.4 9.6 Python 3 3.4 3.5 Samba 4.1 4.5 Vim 7 8 Others: browsers, new MySQL database variant, networking commands Source (as of 8/16/18): https://www.debian.org/releases/stable/amd64/release-notes/ch-whats-new.en.html notes/debian/upgrade-to-debian-stretch.txt (END)

This list comes from the Debian documentation. Also keep in mind, most of these are not preloaded and need to be installed.

The columns in this table show the version located in the Stable repository. So for example, if you install Python 3 using the apt-get install command on Debian 8 you would get Python 3.4 and on Debian 9 you would get 3.5.

That said, you can always install a later version, like Python 3.7, straight from python.org, but the reason many people select the Debian distribution in the first place is because Debian has the best reputation for fully testing software for bugs before putting it in the Stable repository. Granted, it takes them a little longer than most, but for those of us who like stability, a distribution upgrade and everything that comes with it, can be an exciting time.

The Linux kernel upgrades from the 3.16 series to 4.9 series and we will see this transition live in this tutorial.

Worth noting is that for GUI versions of Debian, the web browser Iceweasel was upgraded and now goes under the name Firefox, as naming rights issues were sorted out. Chromium, the open-source version of Google's Chrome browser is included as well.

Probably the biggest news is on the database front. MariaDB is now the default MySQL variant as I'm guessing the folks at Debian weren't thrilled about Oracle being in control of such an important component of the system. The binary data file with MariaDB is not backwards compatible, so make sure you backup your databases.

Also, for system administrators involved with network troubleshooting, I was surprised to see that many of the Internet Protocol commands under the net-tools package like arp, ifconfig, iptunnel, nameif, netstat and route were deprecated in favor of commands in the iproute2 toolset.

For instructions on how to keep those commands on your system, see section 5.3.9 in the Release Notes as introduced later, in Step 4.

b. Be prepared and make backups

Keep in mind that even though Debian's APT package management system is leaned on by many distributions, like Ubuntu, and may be the most stable of the Linux distributions out there, I cannot guarantee your upgrade will go smoothly. If you think about it nearly everyone has a different combination of hardware, software packages and settings.

So please take every precaution to back up your important files and let your users know that the system may be down for an extended period of time.

That said, this is the third server I've upgraded and my previous two attempts went smoothly.

Oh, before we move on, I should mention at the outset, you can only upgrade from version 8 to 9, meaning you can't skip from 7 to 9.

Step 2 - Perform Seven Preliminary Actions on the Debian 8 Jessie System

Okay now for Step 2, we need to take seven actions to prepare the Debian 8 system for this in-place upgrade.

a. Find your Debian version

First, let's get our Debian version number. We can do this one of two ways.

We can print the one-line text file at /etc/debian_version to the screen using the cat command.

paul@fullstack:~$ cat /etc/debian_version 8.11

Or the lsb_release command with the -d flag for the Description.

paul@fullstack:~$ lsb_release -d Description: Debian GNU/Linux 8.11 (jessie)

There you have it, our starting point, Debian 8.11 Jessie.

b. Find your kernel version before the upgrade

We will be upgrading the Linux kernel as mentioned, and using the uname command with the -r option shows the current kernel version.

paul@fullstack:~$ uname -r 3.16.0-4-amd64

By way of background, I'm using an SSH client to remotely access the server-side SSH service currently running on the Debian 8 box. This server happens to be a headless command-line only server without a GUI, so my system is extremely light on resources. This means the time it takes for my system to update and upgrade will likely be faster than yours.

Also, Debian classifies my 64-bit Intel architecture under the name amd64. Your hardware may differ of course, so the output from the uname command may look different depending on your architecture. The Debian documentation files we look at later will differ as well.

We will need to reboot the server to ensure the new Linux kernel is installed, so on my side, I will then have to log in again using SSH, as you would on a cloud-based service.

On the other hand, if you are upgrading your machine locally then you won't have to log in with SSH to confirm the upgrade. We'll cover that in Step 5.

c. See how much space you have on your hard drive

Now let's make sure we have enough space on our hard drive using the df -h command and option for output in "human-readable" form.

paul@fullstack:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 109G 1.9G 102G 2% / udev 10M 0 10M 0% /dev tmpfs 1.6G 41M 1.6G 3% /run tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda1 511M 132k 511M 1% /boot/efi

So this low resource server uses only 2% of a 128 Gigabyte SSD drive, so I'm good here. Later we will be asked to verify if we have enough space.

d. Update the local cache

Next, we need to update the local cache file listing available packages at the Debian repository with the apt-get update command as a superuser.

paul@fullstack:~$ sudo apt-get update

Of course, if you are logged in as the root user, you won't need to precede commands with sudo.

e. Upgrade Debian Jessie 8

After that finishes, we need to upgrade packages using apt-get upgrade followed by apt-get dist-upgrade.

paul@fullstack:~$ sudo apt-get upgrade paul@fullstack:~$ sudo apt-get dist-upgrade

The apt-get dist-upgrade command will be the same one we use later to do the actual upgrade to Debian 9. In this case though we are pointing to the old Debian 8 Jessie repository. In a moment we will point to the Debian Stretch repository.

f. View packages with inconsistencies

The next two commands will identify obsolete or missing packages and those that will be held back from the upgrade, which may cause issues.

paul@fullstack:~$ dpkg -C paul@fullstack:~$ apt-mark showhold paul@fullstack:~$

Should any issues pop up here, resolve them before proceeding.

g. Update sources.list to point to new repositories

Next, we need to point our sources.list configuration file to the Debian 9 repositories as mentioned and there are several ways to do this.

Recall also that we need to be superuser, or root, to modify system-wide configuration files, and first we should backup the original file.

paul@fullstack:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list_jessie paul@fullstack:~$ sudo vim /etc/apt/sources.list

Normally, for a small file like sources.list, I prefer to take a few extra seconds using the Vim editor and modify the file myself instead of using sed, as others do.

Original sources.list file
deb http://ftp.us.debian.org/debian/ jessie main deb-src http://ftp.us.debian.org/debian/ jessie main deb http://security.debian.org/ jessie/updates main deb-src http://security.debian.org/ jessie/updates main # jessie-updates, previously known as 'volatile' deb http://ftp.us.debian.org/debian/ jessie-updates main deb-src http://ftp.us.debian.org/debian/ jessie-updates main

Earlier we accessed the Jessie repository, right? Now we need to modify this file so all references that point to jessie will instead point to stretch.

In Vim we can see matches with /jessie then manually change each occurance from jessie to stretch or do a search and replace by typing :%s/jessie/stretch/gc with g meaning global for the whole file and c to optionally confirm each change.

Two points before we move on, first your mirror locations don't need to match mine.

Second, some people put stable in place of stretch but I don't recommend that, and here is the reason.

Think about it this way. Fast forward two years from now, to mid-2020 when Stretch reaches its end-of-life date, and Debian makes version 10 Buster the stable version. In this case, if you haven't upgraded your system to version 10 this would cause conflicts. So stick with the name stretch to avoid that issue.

Modified sources.list file
deb http://ftp.us.debian.org/debian/ stretch main deb-src http://ftp.us.debian.org/debian/ stretch main deb http://security.debian.org/ stretch/updates main deb-src http://security.debian.org/ stretch/updates main # stretch-updates, previously known as 'volatile' deb http://ftp.us.debian.org/debian/ stretch-updates main deb-src http://ftp.us.debian.org/debian/ stretch-updates main

After we're happy with our changes to the sources.list file, save and close it and we are all set.

Step 3 - Kick Off the Distribution Upgrade to Debian 9 Stretch

Okay for Step 3, we can now start with the same two steps, then kick off the upgrade to Stretch.

a. Update using new repositories

As with any package management operation using Debian's APT system, we must start with an apt-get update.

paul@fullstack:~$ sudo apt-get update

This update will take a bit longer than the original cache refresh because we are pointing to the new repository, right? The one for Stretch.

(Note too that you could always put the update and the next step, the upgrade on the same line to run the upgrade automatically only if the update completes without error, using sudo apt-get update && sudo apt-get upgrade. You can also add the -y option to the upgrade to accept all defaults if you don't want to monitor it. Here I wanted to be more deliberate for the sake of the tutorial.)

b. Upgrade using new repositories

Next, we need to perform what is called a minimal system upgrade for those packages that can be upgraded without a lot of dependency management, meaning adding or deleting other packages. That's what the apt-get upgrade command does here.

paul@fullstack:~$ sudo apt-get upgrade

Again this should take only a few moments on my low-resource machine but yours could take as long as five minutes.

c. Perform the distribution upgrade

Okay, now we're ready to kick off the longest part of the upgrade, the distribution upgrade. For that we use the sudo apt-get dist-upgrade command, again as superuser we need to precede it with sudo, but as root we do not.

paul@fullstack:~$ sudo apt-get dist-upgrade

We may be asked to confirm whether obsolete or conflicting packages should be removed, and you know your system better than I do, so you are better equipped to make those decisions.

Also, on requests to restart services, you may elect to avoid being prompted or sign-off on each service restart individually. Again, I will leave that decision up to you.

While that is running, let me show you those helpful pages on debian.org and we will return to clean up obsolete packages, then reboot the system, which installs the new kernel.

Step 4 - Find Suggested Readings at debian.org

For Step 4, let's access debian.org in a browser so you can increase your comfortable level before getting started. If your system is in a production environment with many users and active databases then it is a good idea to pore over the official documents.

a. Debian 9 Release Notes

The main document that guides you through the upgrade is called Release Notes. A link to the document for my 64-bit PC Intel architecture, called amd64 is provided in the Comments section of the video (and below).

If your system uses different architecture, like ARM or MIPS, the Release Information page has links to similar documents.

In the Release Notes you will find all of the gory details of Stretch: a What's New section, changes to the installation system, steps for the upgrade from Jessie, known issues and other readings. Appendix A includes tasks to do on Jessie before the upgrade.

I suggest at least browsing through that, especially if you are upgrading a production machine. Computers with lots of third-party software will increase the likelihood of complications, so keep that in mind.

It is recommmended that you have a full system backup or a backup of important files at least, like those in the /etc and /home directories at a minimum.

If yours is a virtual machine taking a snapshot is a must as well.

Step 5 - Ensure that the OS Upgrade was Successful

Now for Step 5 we need to remove unwanted packages, perform that reboot and then, I will open a new SSH window to see if I can log in and verify the upgrade was successful.

a. Clean up with autoremove

First, let's clean up and save a little disk space with the apt-get autoremove command.

paul@fullstack:~$ sudo apt-get autoremove

This will remove unnecessary packages and shouldn't take too long.

b. Reboot the system

Next, as a superuser let's reboot the system and then open a new SSH window and try out Debian 9 Stretch.

paul@fullstack:~$ sudo reboot

Before we finish and confirm that everything went smoothly, in the meantime let me mention that I will drop additional tutorials like this one into a YouTube Playlist dedicated to Linux and on the website in the future, so subscribe if you would like to be notified about those.

I also publish tutorials on Vim, Apache Solr, Data Science and quantitative finance topics, so you can explore those as well.

Recall, I'm using SSH to communicate with the server remotely, so let me open a new window and see if we have given the server enough time to reboot.

(At the same time we will test to see whether the SSH service on the server restarted without issue.)

Now the server will return a command prompt so I can sign in to Debian Stretch.

c. Find your Debian and kernel versions after the upgrade

Great! Now let's bring back the lsb_release and uname commands from earlier run on one line and see if we were successful.

paul@fullstack:~$ lsb_release -d; uname -r Description: Debian GNU/Linux 9.5 (stretch) 4.9.0-6-amd-64

Looks good, we are running Stretch with the new 4.9 series kernel, and are ready to wrap up. I hope going through it like this saves you some time.

The experience you go through with your particular hardware and installed packages may help someone else, so please share your experiences in the YouTube Comments section.

Also, while there, please share, like and subscribe if you support my goal of providing consistently-formatted higher-quality tutorials in both video and print.

Also, I love honest feedback, so let me know areas where I can improve.

Thank you for your time and have a nice day.


Related Content


What's Next?

For those reminders, subscribe at YouTube, follow @Twitter and at our no-spam email list.

Outline Back Tip Next

/ factorpad.com / tech / linux / tutorial / upgrade-to-debian-stretch.html


upgrade debian 8 to 9
upgrade to debian stretch
apt-get dist-upgrade
debian distribution upgrade
linux server os upgrade
debian stretch upgrade
debian 9 upgrade
upgrade to debian 9
debian stable upgrade
debian dist upgrade
check debian version
linux upgrade
debian server upgrade
sudo apt-get dist-upgrade
debian 9
debian stretch
debian sources list
debian linux
linux tutorial
linux examples
in-place upgrade

A newly-updated free resource. Connect and refer a friend today.