/ factorpad.com / tech / linux / tutorial / upgrade-to-debian-stretch.html
An ad-free and cookie-free website.
Intermediate
Learn to upgrade your Debian-based Linux operating system with step-by-step instructions in both video and text.
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)
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.
Let's start with Step 1 and cover what's new in Debian 9.
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.
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.
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.
Okay now for Step 2, we need to take seven actions to prepare the Debian 8 system for this in-place upgrade.
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.
Or the lsb_release
command with the
-d
flag for the Description.
There you have it, our starting point, Debian 8.11 Jessie.
We will be upgrading the Linux kernel as mentioned, and using the
uname
command with the
-r
option shows the current kernel
version.
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.
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.
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.
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.
Of course, if you are logged in as the root user, you won't need to
precede commands with sudo
.
After that finishes, we need to upgrade packages using
apt-get upgrade
followed by
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.
The next two commands will identify obsolete or missing packages and those that will be held back from the upgrade, which may cause issues.
Should any issues pop up here, resolve them before proceeding.
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.
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.
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.
After we're happy with our changes to the
sources.list
file, save and close it
and we are all set.
Okay for Step 3, we can now start with the same two steps, then kick off the upgrade to Stretch.
As with any package management operation using Debian's APT
system, we must start with an
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.)
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.
Again this should take only a few moments on my low-resource machine but yours could take as long as five minutes.
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.
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.
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.
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.
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.
First, let's clean up and save a little disk space with the
apt-get autoremove
command.
This will remove unnecessary packages and shouldn't take too long.
Next, as a superuser let's reboot the system and then open a new SSH window and try out Debian 9 Stretch.
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.
Great! Now let's bring back the
lsb_release
and
uname
commands from earlier run on
one line and see if we were successful.
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.
For those reminders, subscribe at YouTube, follow @Twitter and at our no-spam email list.
/ factorpad.com / tech / linux / tutorial / upgrade-to-debian-stretch.html
A newly-updated free resource. Connect and refer a friend today.