Debian – How to revert Debian from testing to stable

debiantestingupgrade

I have a PC that is used not so often.
Like half a year ago someone changed its repositories from stable to testing and updated/upgraded. After that no one updated or upgraded.
Can I change in /etc/apt/sources.list all back to stable and do a

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

Or I will face some errors?

Best Answer

If you switch back to stable by replacing “testing” with “stable”, you won’t get any errors, but you’ll pretty much stay stuck with whatever versions of the packages you have currently, at least those which were upgraded to “testing” versions: they are all newer than the corresponding versions in Debian 9, and apt won’t downgrade by default.

(Note that you should specify “stretch” in your sources.list, rather than “stable”; otherwise you’ll end up upgrading to Debian 10 as soon as it’s released, rather than when you choose to do so.)

If you want to fully revert to Debian 9, you’ll need to downgrade your packages. You can do that manually, by investigating the packages which were upgraded:

apt list --installed | grep /testing

or

apt list --installed | grep /now

will tell you what they are. (The /testing variant will work if your sources.list still include “testing”, the /now variant will work otherwise.)

Or you can do it “automatically”, by pinning “stretch” to 1001; add the following to /etc/apt/preferences, creating it if necessary:

Package: *
Pin: release n=stretch
Pin-Priority: 1001

Then apt dist-upgrade will attempt to downgrade all appropriate packages to their Debian 9 version. Note that this is untested and unsupported (downgrades aren’t supported as a general rule), so do pay close attention to what apt is going to do before letting it proceed.

You can reduce the amount of work involved in all this by adding Stretch backports, since that has versions of some packages which are closer to those in testing; add

deb http://http.debian.net/debian stretch-backports main

to your sources.list.

Related Question