How to Upgrade Debian 9 (Stretch) to 10 (Buster)

What’s new in Debian 10?

  • Updated desktop environments such as Cinnamon 3.8, GNOME 3.30, KDE Plasma 5.14, LXDE 0.99.2, LXQt 0.14, MATE 1.20, Xfce 4.12.
  • Secure Boot support greatly improved
  • AppArmor is installed and enabled by default
  • Apache
  • BIND
  • Chromium
  • Emacs
  • Firefox
  • GIMP
  • GNU
  • GnuPG
  • Golang
  • Inkscape
  • LibreOffice
  • Linux
  • MariaDB
  • OpenJDK
  • Perl
  • PHP
  • PostgreSQL
  • Python
  • Ruby
  • Rustc
  • Samba
  • systemd
  • Thunderbird
  • Vim

Upgrade Debian 9 to Debian 10 Buster

The procedure is as follows:

  1. Backup your system. Typically I create a snapshot.
  2. Update existing packages and reboot the Debian 9.x system.
  3. Edit the file /etc/apt/sources.list using a text editor and replace each instance of stretch with buster.
  4. Update the packages index on Debian Linux, run: sudo apt update
  5. Prepare for the operating system upgrade, run: sudo apt upgrade
  6. Finally, update Debian 9 to Debian 10 buster by running: sudo apt full-upgrade
  7. Reboot the Linux system so that you can boot into Debian 10 Buster
  8. Verify that everything is working correctly.

Let us see all command in details.

Step 1. Backup your system

It is crucial to backup all data and system configurations. Cloud-based VMs can be quickly backup and restore using snapshots. Check OS:
lsb_release -a
Sample outputs:

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.12 (stretch)
Release:	9.12
Codename:	stretch

Note down the Linux kernel too:
uname -mrs
Sample outputs:

Linux 4.9.0-12-amd64 x86_64

Step 2. Update installed packages

Type the following :
sudo apt update
sudo apt upgrade
sudo apt full-upgrade
sudo apt --purge autoremove

OR
sudo apt-get update
sudo apt-get upgrade
sudo apt-get full-upgrade
sudo apt-get --purge autoremove

reboot to apply the kernel and other updates:
sudo reboot

Step 3. Update /etc/apt/sources.list file

Before starting the upgrade you must reconfigure APT’s source-list files. 

To view current settings using :
cat /etc/apt/sources.list
Sample outputs:

The stretch indicates that we are using an older version. Hence, we must change all the references in this file from Stretch to Buster using a text editor such as vim:
vi /etc/apt/sources.list
I prefer to use sed tool, but first backup all config files using the cp command:
sudo cp -v /etc/apt/sources.list /root/
sudo cp -rv /etc/apt/sources.list.d/ /root/
sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list
sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/*
### see updated file now ###
cat /etc/apt/sources.list


APT source-list files updated to use buster

Updating the package list

Simply run:
sudo apt update


Step 4. Minimal system upgrade

A two-part process is necessary to avoid the removal of large numbers of packages that you want to keep. Therefore, first run the following:
sudo apt upgrade



Just follow on-screen instructions. During the upgrade process, you may get various questions, like “Do you want to restart the service? ” OR “keep or erase config options” and so on. For example, I got a screen as follows indicating new changes:



Press ‘q‘ to exit and further you may see additional screens:



And:


Step 5. Upgrading Debain 9 to Debian 10

In addition, minimum upgrades we need to do full upgrades to finish the whole Debian 9 to Debian 10 update process. This is the main part of the upgrade. In other words, execute the following command to perform a complete upgrade of the system, installing the newest available versions of all packages, and resolving all possible dependency:
sudo apt full-upgrade

Reboot the System to boot into Debian Linux 10 buster, issue:
sudo reboot

Step 6. Verification

It is time to confirm the upgrade. Run:
uname -r
lsb_release -a

Sample outputs:

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 10 (buster)
Release:	10
Codename:	buster

Finally, clean up outdated packages using :
sudo apt --purge autoremove


Conclusion

And there you have it. We have successfully upgraded to Debian Linux 10. 
source: cyberciti.biz