Checking packages status
Regardless of the method used for upgrading, it is recommended that you check the status of all packages first, and verify that all packages are in an upgradable state. The following command will show any packages which have a status of Half-Installed or Failed-Config, and those with any error status.
# dpkg --audit
You could also inspect the state of all packages on your system using aptitude or with commands such as
# dpkg -l | pager
or
# dpkg --get-selections "*" > ~/curr-pkgs.txt
It is desirable to remove any holds before upgrading. If any package that is essential for the upgrade is on hold, the upgrade will fail.
Note that aptitude uses a different method for registering packages that are on hold than apt and dselect. You can identify packages on hold for aptitude with
# aptitude search "~ahold"
If you want to check which packages you had on hold for apt, you should use
# dpkg --get-selections | grep 'hold$'
If you changed and recompiled a package locally, and didn't rename it or put an epoch in the version, you must put it on hold to prevent it from being upgraded.
The “hold” package state for apt can be changed using:
# echo package_name hold | dpkg --set-selections
Replace hold with install to unset the “hold” state.
If there is anything you need to fix, it is best to make sure your APT source-list files still refer to stretch as explained in Section A.2, “Checking your APT source-list files”.
4.3. Preparing APT source-list files
Before starting the upgrade you must reconfigure APT's source-list files (/etc/apt/sources.list and files under /etc/apt/sources.list.d/).
APT will consider all packages that can be found via any configured archive, and install the package with the highest version number, giving priority to the first entry in the files. Thus, if you have multiple mirror locations, list first the ones on local hard disks, then CD-ROMs, and then remote mirrors.
A release can often be referred to both by its codename (e.g. stretch, buster) and by its status name (i.e. oldstable, stable, testing, unstable). Referring to a release by its codename has the advantage that you will never be surprised by a new release and for this reason is the approach taken here. It does of course mean that you will have to watch out for release announcements yourself. If you use the status name instead, you will just see loads of updates for packages available as soon as a release has happened.
Debian provides two announcement mailing lists to help you stay up to date on relevant information related to Debian releases:
By subscribing to the Debian announcement mailing list, you will receive a notification every time Debian makes a new release. Such as when buster changes from e.g. stable to oldstable.
By subscribing to the Debian security announcement mailing list, you will receive a notification every time Debian publishes a security announcement.
4.3.1. Adding APT Internet sources
On new installations the default is for APT to be set up to use the Debian APT CDN service, which should ensure that packages are automatically downloaded from a server near you in network terms. As this is a relatively new service, older installations may have configuration that still points to one of the main Debian Internet servers or one of the mirrors. If you haven't done so yet, it is recommended to switch over to the use of the CDN service in your APT configuration.
To make use of the CDN service, add a line like this to your APT source configuration (assuming you are using main and contrib):
deb http://deb.debian.org/debian buster main contrib
After adding your new sources, disable the previously existing “deb” lines by placing a hash sign (#) in front of them.
However, if you get better results using a specific mirror that is close to you in network terms, this option is still available.
Debian mirror addresses can be found at https://www.debian.org/distrib/ftplist (look at the “list of Debian mirrors” section).
For example, suppose your closest Debian mirror is http://mirrors.kernel.org. If you inspect that mirror with a web browser, you will notice that the main directories are organized like this:
http://mirrors.kernel.org/debian/dists/buster/main/binary-amd64/...
http://mirrors.kernel.org/debian/dists/buster/contrib/binary-amd64/...
To configure APT to use a given mirror, add a line like this (again, assuming you are using main and contrib):
deb http://mirrors.kernel.org/debian buster main contrib
Note that the “dists” is added implicitly, and the arguments after the release name are used to expand the path into multiple directories.
Again, after adding your new sources, disable the previously existing archive entries.
4.3.2. Adding APT sources for a local mirror
Instead of using remote package mirrors, you may wish to modify the APT source-list files to use a mirror on a local disk (possibly mounted over NFS).
For example, your package mirror may be under /var/local/debian/, and have main directories like this:
/var/local/debian/dists/buster/main/binary-amd64/...
/var/local/debian/dists/buster/contrib/binary-amd64/...
To use this with apt, add this line to your sources.list file:
deb file:/var/local/debian buster main contrib
Note that the “dists” is added implicitly, and the arguments after the release name are used to expand the path into multiple directories.
After adding your new sources, disable the previously existing archive entries in the APT source-list files by placing a hash sign (#) in front of them.
4.3.3. Adding APT sources from optical media
If you want to use only DVDs (or CDs or Blu-ray Discs), comment out the existing entries in all the APT source-list files by placing a hash sign (#) in front of them.
Make sure there is a line in /etc/fstab that enables mounting your CD-ROM drive at the /media/cdrom mount point. For example, if /dev/sr0 is your CD-ROM drive, /etc/fstab should contain a line like:
/dev/sr0 /media/cdrom auto noauto,ro 0 0
Note that there must be no spaces between the words noauto,ro in the fourth field.
To verify it works, insert a CD and try running
# mount /media/cdrom # this will mount the CD to the mount point
# ls -alF /media/cdrom # this should show the CD's root directory
# umount /media/cdrom # this will unmount the CD
Next, run:
# apt-cdrom add
for each Debian Binary CD-ROM you have, to add the data about each CD to APT's database.
4.4. Upgrading packages
The recommended way to upgrade from previous Debian releases is to use the package management tool apt.
[Note] Note
apt is meant for interactive use, and should not be used in scripts. In scripts one should use apt-get, which has a stable output better suitable for parsing.
Don't forget to mount all needed partitions (notably the root and /usr partitions) read-write, with a command like: