Upgrade Debian 8 Jessie to Debian 9 Stretch
This guide explains how to upgrade your Debian Linux system from Debian 8 (Jessie) to Debian 9 (Stretch) which was released on 2017-06-17.
These steps can be preformed as an in place upgrade on a live system from either a local terminal or remote SSH session.
Step 1
Prior to upgrading, make sure the current system is up-to-date.
apt-get update && apt-get upgrade
Step 2
Begin the upgrade by switching Debian repositories from Jessie to Stretch. This is accomplished in one of two ways; using the sed command to search and replace all instances automatically, or by editing the source file manually. Choose whichever option you prefer.
Search & Replace with sed.
sed -i 's/jessie/stretch/g' /etc/apt/sources.list
Or edit your source list manually.
vi /etc/apt/sources.list
Replace all instances of "jessie" with "stretch" , for example.
deb http://ftp.us.debian.org/debian/ jessie main non-free contrib deb-src http://ftp.us.debian.org/debian/ jessie main non-free contrib deb http://security.debian.org/ jessie/updates main contrib non-free deb-src http://security.debian.org/ jessie/updates main contrib non-free deb http://ftp.us.debian.org/debian/ jessie-updates main contrib non-free deb-src http://ftp.us.debian.org/debian/ jessie-updates main contrib non-free
Becomes.
deb http://ftp.us.debian.org/debian/ stretch main non-free contrib deb-src http://ftp.us.debian.org/debian/ stretch main non-free contrib deb http://security.debian.org/ stretch/updates main contrib non-free deb-src http://security.debian.org/ stretch/updates main contrib non-free deb http://ftp.us.debian.org/debian/ stretch-updates main contrib non-free deb-src http://ftp.us.debian.org/debian/ stretch-updates main contrib non-free
Note: Debian is distributed (mirrored) on hundreds of servers worldwide. In our source.list example above we've used a repository within the United States, to speed up downloads you may choose another Debian mirror based on geographic location.
Step 3
Update the package index.
apt-get update
Step 4
Upgrade the minimal base system.
apt-get upgrade
Step 5
Upgrade all other packages and dependencies.
apt-get dist-upgrade
Step 6
Reboot the system.
reboot
Step 7
Verify your release is now Debian 9.
lsb_release -a
Output will be similar to this.
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 9.0 (stretch) Release: 9.0 Codename: stretch
Step 8
Verify Kernel version.
uname -mrs
Output will be similar to this.
Linux 4.9.0-3-amd64 x86_64
Step 9
Optionally, free up some disk space by clearing the local repository of retrieved package files.
apt-get clean
apt-get autoremove