How to upgrade Debian Stretch to Buster


Debian makes it easy to upgrade to new releases and this tutorial will show you how to safely upgrade your Debian 9 Stretch install to the new Debian 10 Buster release.

Preparing for the upgrade to Buster

The very first thing you should do in preparation for the upgrade is backup your important files. While Debian upgrades usually go smoothly, you should always be prepared for a worst case scenario and have all of your important files that you couldn’t do without, backed up.

You should also make a list of all you currently installed packages with the following command

sudo dpkg --get-selections > debian-package-backup

Note: Upgrading Debian between releases is best done with a pure Debian system. This tutorial also assumes that you have a fully up-to-date Stretch install.

Update Debian package repos to Buster

To upgrade Debian Stretch to Debian Buster, you must first point your Debian package repository list to the new Debian Buster release. To do this you’ll want to open up /etc/apt/sources.list with your favorite text editor (I’m using nano for this tutorial) like so

sudo nano /etc/apt/sources.list

and replace every instance of “stretch” with “buster” until it looks like the following:

deb buster main
deb-src buster main

deb buster/updates main
deb-src buster/updates main

# buster-updates, previously known as 'volatile'
deb buster-updates main
deb-src buster-updates main

# buster-backports, previously on
deb buster-backports main
deb-src buster-backports main
Updating Debian Stretch's package list to Debian 10 Buster
An example/screenshot of editing /etc/apt/sources.list in nano and having completed the step of updating every instance of “stretch” to “buster”

Once that’s done, save the file and exit (to save with nano use: CTRL+O and to exit use: CTRL+X).

Note: If you prefer an easier way to update /etc/apt/sources.list you can use sed to replace every instance of stretch with buster by running the following command:

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

Once your /etc/apt/sources.list has been updated to point to buster, you must now refresh the Debian package index with

sudo apt update

Now that you have successfully refreshed the package index, it’s time to move on to the actual upgrade!

Note: After running “apt update” you can see which packages will be updated during the upgrade to Buster with:

sudo apt list --upgradable

Begin the upgrade

Once you are ready to start the upgrade from Debian 9 Stretch to Debian 10 Buster you can begin by issuing the below command

sudo apt full-upgrade

You’ll see a bunch of text fly down your screen as apt upgrades, installs, and configures your packages to upgrade your Debian OS from Stretch to Debian 10 Buster. The upgrade will take a few minutes (or a little longer, depending on how powerful your computer or server is).

During the upgrade you might be asked whether you would like to have services restarted automatically for you

You can select “Yes” if you would like to have services restarted automatically during the upgrade without bringing up a prompt every time a service needs to be restarted.

You might also be asked about what to do with system files you may have modified since installing your original Debian install. You’ll be shown a screen similar to below and you can choose to install the new (and updated) configuration file over your old modified one or you can choose to keep your currently installed modified file. This prompt also gives you the option to examine and show the differences between the files.

Note: The default option is to keep your currently installed version. If you choose the default option and keep your currently installed version then the new version that you chose not to install will be stored with a “.ucf-dist” added to the end.

Configuration file '/etc/sysctl.conf'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** sysctl.conf (Y/I/N/O/D/Z) [default=N] ?
An example of being asked what to do with my modified /etc/sysctl.conf file during the upgrade from Debian Stretch to Buster.
Another example of being asked what to do when there’s a new version of a configuration file available (ie. /etc/ssh/sshd_config) when performing an upgrade from Debian Stretch to Buster.

After the apt full-upgrade command is done running you can proceed to the next step to clean up old and unused packages.

Remove any packages that are no longer needed

Once the upgrade is complete, you can choose to remove any packages that are no longer needed by issuing this command

sudo apt autoremove

Note: If you would like to also purge any old configuration files that were used by those packages that are no longer needed than you can add –purge to the end of the apt autoremove command like this:

sudo apt autoremove --purge


The last step in the upgrade process is to reboot your system

sudo systemctl reboot


After you have rebooted you can verify that you are running Debian 10 Buster with the “lsb_release -a” command

root@debian-vm:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster

and you can see your current kernel version with the “uname -a” command

root@debian-vm:~# uname -a
Linux debian-vm 4.19.0-5-amd64 #1 SMP Debian 4.19.37-3 (2019-05-15) x86_64 GNU/Linux

Congratulations! You have hopefully successfully completed the upgrade from Debian 9 Stretch to Debian 10 Buster! Whoohoo!

If you have any questions or comments about this tutorial, please leave a comment below or you can also contact me privately.

3 Replies to “How to upgrade Debian Stretch to Buster”

Leave a Reply

Your email address will not be published. Required fields are marked *