debian How to Upgrade Debian 8 Jessie to Debian 9 Stretch

How to Upgrade Debian 8 Jessie to Debian 9 Stretch

 

Debian 9 Stretch was released as the latest stable version of the Linux Debian operating system today. While you can install Debian 9 Stretch fresh, you can also perform an in place upgrade from Debian 8 Jessie quite easily, which is what we will cover here.

 

For full documentation on the process, it is suggested that you also read through the official release notes.

Notes:

  • Upgrading to Debian 9 Stretch is only supported from Debian 8 Jessie. If you are running a version older than 8, you must first upgrade to 8 before working through this process.
  • The upgrade involves a kernel update, so a reboot will be required toward the end of the process.
  • It is strongly recommended that you have a full system backup or backup of any important data before proceeding with the upgrade, ensure that you have a plan to roll back. In the case of a virtual machine, take a snapshot before starting.

Performing the upgrade to Debian 9 Stretch

In this example we’ll be upgrading from Debian 8.8.

root@debian8:~# cat /etc/debian_version
8.8

Before proceeding with the upgrade, please read through the list of issues to be aware of when upgrading to Stretch.

  1. It is recommended that you have your Debian 8 Jessie installation completely up to date before starting, to do this run “apt-get update” followed by “apt-get upgrade” and install available updates.
    root@debian8:~# apt-get update
    root@debian8:~# apt-get upgrade
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    

    In my case all updates have been applied already, so it’s fine to proceed.

  2. Edit the /etc/apt/sources.list file, my file is shown below. As you can see all of the lines are currently specifying “jessie”. Note that your mirror sources will likely be different which is fine.
    deb http://debian.uberglobalmirror.com/debian/ jessie main
    deb-src http://debian.uberglobalmirror.com/debian/ jessie main
    
    deb http://security.debian.org/ jessie/updates main contrib
    deb-src http://security.debian.org/ jessie/updates main contrib
    
    # jessie-updates, previously known as 'volatile'
    deb http://debian.uberglobalmirror.com/debian/ jessie-updates main contrib
    deb-src http://debian.uberglobalmirror.com/debian/ jessie-updates main contrib
    

    Change the instances of “jessie” to “stretch”, you can either do this manually, or automatically with the below sed command.

    sed -i 's/jessie/stretch/g' /etc/apt/sources.list
    

    my new sources.list file is shown below.

    deb http://debian.uberglobalmirror.com/debian/ stretch main
    deb-src http://debian.uberglobalmirror.com/debian/ stretch main
    
    deb http://security.debian.org/ stretch/updates main contrib
    deb-src http://security.debian.org/ stretch/updates main contrib
    
    # stretch-updates, previously known as 'volatile'
    deb http://debian.uberglobalmirror.com/debian/ stretch-updates main contrib
    deb-src http://debian.uberglobalmirror.com/debian/ stretch-updates main contrib
    

    You can either use “stretch” or “stable”, as Debian 9 Stretch is now the current stable version as of writing. However note that if you use stable instead of the specific release name, in future when Debian 10 is released that will be the stable version so you may upgrade to that unintentionally.

  3. The recommended way to upgrade Debian is with the ‘apt-get’ command. First update the list of available packages with the below command, as we’ve just updated the sources.list file.
    apt-get update
    
  4. Now that the list of available packages has been updated from the mirror, run the below command to perform a minimal upgrade.
    apt-get upgrade
    

    This is known as a minimal system upgrade as it only upgrades packages that can be upgraded without needing any other packages to be removed or installed, so it’s a safe place to start. This upgraded 932 packages requiring 412MB on my system.

  5. Now you’re ready to do the complete system upgrade, this will upgrade to the latest available version for all packages installed.
    apt-get dist-upgrade
    

    Ensure that you have enough free disk space to complete the operation, in my case it notes that afterwards 1,048MB of additional disk space will be used with 639 package upgrades and 479 newly installed packages.

    Note that this will remove conflicting obsoleted packages, potentially packages that you may want to keep, so check what it’s going to do by reading the output before proceeding.

  6. Once the upgrade has completed you may have packages that can be removed and are no longer required, you’ll see these when trying to use apt-get upgrade. We can clean these out by running “apt-get autoremove”.
    apt-get autoremove
    

    This cleaned 496MB of packages from my system that were identified as no longer being required after the upgrade.

  7. All that’s left to do is perform a reboot of the system, this is required as the kernel version has been updated. This can be done by simply entering “reboot” in the terminal.
    Before upgrade:
    root@debian8:~# uname -a
    Linux debian8 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux
    
    After upgrade and system reboot:
    root@debian8:~# uname -a
    Linux debian8 4.9.0.3-amd64 #1 SMP Debian 4.9.30-2 (2017-06-12) x86_64 GNU/Linux
    

    As you can see the newer kernel version 4.9 is now in place after rebooting.

    You can also check the /etc/debian_version file to confirm that you’re on version 9.

    root@debian8:~# cat /etc/debian_version
    9.0
    

    Now I just need to change my “debian8” hostname!

Debian 9 Stretch

Summary

As shown it’s quite a simple process to complete an in place upgrade from Debian 8 Jessie to Debian 9 Stretch. The process involves fully updating your Debian 8 installation, modifying the /etc/apt/sources.list file by changing instances of “jessie” to “stretch”, running an ‘apt-get update’, ‘apt-get upgrade’, followed by a ‘apt-get dist-upgrade’ and then finally a reboot so that the newer kernel version will be used.

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
How To Create a Linux Swap File
Viewed 2359 times since Fri, Jun 8, 2018
How to stop and disable auditd on RHEL 7
Viewed 39671 times since Tue, Aug 6, 2019
systemctl Use systemd to Start a Linux Service at Boot
Viewed 5659 times since Mon, Dec 7, 2020
debian How to check Debian CVE status using python script
Viewed 3498 times since Sun, Sep 23, 2018
Using Kerberos security with Server for NFS
Viewed 9493 times since Wed, Jun 27, 2018
Linux / UNIX: Run Command a Number of Times In a Row
Viewed 15812 times since Tue, Aug 6, 2019
How log rotation works with logrotate
Viewed 4804 times since Fri, Nov 30, 2018
What is OS Watcher Utility and How to use it for Database Troubleshooting ?
Viewed 29937 times since Thu, Jun 21, 2018
Install Security Patches or Updates Automatically on CentOS and RHEL
Viewed 1700 times since Fri, Oct 26, 2018
Inxi: Find System And Hardware Information On Linux
Viewed 2197 times since Sat, Jun 2, 2018