# Upgrade Debian 8 to Debian 9

The pourpouse of this leccion is to upgrade Debian 8 to Debian 9 so we could use all the feautures of OpenCV 3.3.0.

Before to start this upgrade, we need to fully upgrade our current Debian Jessie system:

```
# apt-get update
# apt-get upgrade
# apt-get dist-upgrade
```

If everything was correct , we need to perform database sanity and consistency checks for partially installed, missinig and obsolete packages:

```
# dpkg -C
```

If no issues are reported, we need to check what package are held back:

```
# apt-mark showhold
```

Once we have our current system fully upgrade, it is time to resynchronize the package index files with new Debian Stretch sources. This is done by editing /etc/apt/source.list file to include Debian stretch package repository. Before doing this we need to this file:

```
# cp /etc/apt/sources.list /etc/apt/sources.list_backup
```

Now we execute _apt edit-sources._ Once we could edit we need to change every jessie for a stretch.

Example:

```
FROM JESSIE
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
TO STRETCH
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
```

Once we finish to edit the file, we are going to use _apt-get_ command to update packages index:

```
# apt-get update
```

Now we are going to make the upgrade to Debian Stretch system. During the upgrade you may be asked:

> There are services installed on your system which need to be restarted when certain libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may cause interruptions of service for the system, you will normally be prompted on each upgrade for the list of services you wish to restart. You can choose this option to avoid being prompted; instead, all necessary restarts will be done for you automatically so you can avoid being asked questions on each library upgrade.
>
> **Restart services during package upgrades without asking?**

The choice is about whether you wish the system to restart your services automatically during the system upgrade or you wish to do it manually or after the system is fully upgrade to Stretch. When ready, execute the bellow commands to commence the Debian Stretch upgrade process:

```
# apt-get upgrade
# apt-get dist-upgrade
```

At this stage you should have your Jessie Debian Linux system fully upgraded to Debian Stretch. Finally make a reboot to your system.

```
# reboot
```
