Debian – How to upgrade to Debian 9

In this article, we will show you how to upgrade from Debian 7 (wheezy) to Debian 9 (stretch)

1. Debian code name

First, understand the Debian code name, read this Debian releases


Debian 9 (stretch)
Debian 8 (jessie)
Debian 7 (wheezy)
Debian 6 (squeeze)

P.S On Debian 7, first upgrade to Debian 8, then Debian 9, we must follow the correct order to upgrade Debian.

2. Upgrade Debian 7 to Debian 8

2.1 On Debian 7, make sure everything is up to date.

Terminal

$ cat /etc/debian_version
7.5

$ sudo apt-get update
$ sudo apt-get upgrade

2.2 Edit /etc/apt/sources.list. The server urls is vary depending on your hosting provider. it’s fine, we just want to update the Debian 7 code name (wheezy).

/etc/apt/sources.list

deb http://mirrors.linode.com/debian/ wheezy main
deb-src http://mirrors.linode.com/debian/ wheezy main

deb http://mirrors.linode.com/debian-security/ wheezy/updates main
deb-src http://mirrors.linode.com/debian-security/ wheezy/updates main

deb http://mirrors.linode.com/debian/ wheezy-updates main
deb-src http://mirrors.linode.com/debian/ wheezy-updates main

P.S This example is tested under a Linode server.

2.3 Update /etc/apt/sources.list to Debian 8 code name (jessie).

/etc/apt/sources.list

deb http://mirrors.linode.com/debian/ jessie main
deb-src http://mirrors.linode.com/debian/ jessie main

deb http://mirrors.linode.com/debian-security/ jessie/updates main
deb-src http://mirrors.linode.com/debian-security/ jessie/updates main

deb http://mirrors.linode.com/debian/ jessie-updates main
deb-src http://mirrors.linode.com/debian/ jessie-updates main

2.4 Save and exit, do the normal update and upgrade process.

Terminal

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade

2.5 Restart the server. Done. The Debian is upgraded from 7 to 8.

Terminal

# Restart the server
$ sudo reboot

$ cat /etc/debian_version
8.x

2.6 Post upgrade.

Terminal

# remove unused packages.
$ sudo apt-get autoremove

3. Upgrade Debian 8 to Debian 9

The process is the same like an upgrade from Debian 7 to 8.

3.1 Make sure everything is up to date.

Terminal

$ cat /etc/debian_version
8.x

$ sudo apt-get update
$ sudo apt-get upgrade

3.2 Update /etc/apt/sources.list to Debian 9 code name (stretch).

/etc/apt/sources.list

deb http://mirrors.linode.com/debian/ stretch main
deb-src http://mirrors.linode.com/debian/ stretch main

deb http://mirrors.linode.com/debian-security/ stretch/updates main
deb-src http://mirrors.linode.com/debian-security/ stretch/updates main

deb http://mirrors.linode.com/debian/ stretch-updates main
deb-src http://mirrors.linode.com/debian/ stretch-updates main

3.3 Update and upgrade.

Terminal

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade

3.4 Restart the server. Done. The Debian is upgraded from 8 to 9.

Terminal

# Restart the server
$ sudo reboot

$ cat /etc/debian_version
9.5

4. FAQs

4.1 Some /etc/apt/sources.list examples.

Debian 9 (stretch)

/etc/apt/sources.list

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

Debian 8 (jessie)

/etc/apt/sources.list

deb http://httpredir.debian.org/debian jessie main
deb http://httpredir.debian.org/debian jessie-updates main
deb http://security.debian.org jessie/updates main

Debian 7 (wheezy)

/etc/apt/sources.list

deb http://httpredir.debian.org/debian wheezy main
deb http://httpredir.debian.org/debian wheezy-updates main
deb http://security.debian.org wheezy/updates main

4.2 What will happen to the things that already installed/configured? Can they break?
A: Yes, it may, during the upgrade process, if the System found any conflicts, it will prompt you and ask you what should do next, keep the old file or replace with the latest. After upgraded, just test every core services like Nginx, Apache, MySQL, etc, to make sure they are running fine.

References

  1. Wikipedia – Debian
  2. apt-get manual:
  3. Debian – Upgrades from Debian 8 (jessie)
  4. How to check Debian version

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

avatar