1. Upgrading from Debian 8 to 9
1.1. Debian 9 unleashed
After 2 years of development, Debian 9 (codenamed “Stretch”) was released to the awaiting Linux community. The release of Debian 9 is a watershed event because it is the distro’s first major release since the passing away of its founder, Ian Murdock, thereby signalling that the project will continue to thrive in the new era.
Aside from the usual package upgrades in every release, Debian 9 has added over 15,000 new packages in its 51,000 strong repository. Notable new features and changes include the following:
PHP has been upgraded from version 5.6 in Debian 8 to 7.0 in Debian 9. If you have written scripts that involve PHP, note that the executable pathnames for the 2 versions differ significantly.
MariaDB is a fork and a drop-in replacement of the original MySQL software. Debian 9 makes MariaDB the default MySQL variant. When you upgrade from Debian 8 to 9, your existing MySQL database is automatically converted to MariaDB 10.1. You should do a complete database dump before upgrading Debian.
Firefox and Thunderbird
If you look for Iceweasel and Icedove in Debian 9, you won’t find them. After over 10 years, Firebox and Thunderbird, the branded versions of the 2 aforementioned software, make their grand re-entrance in Debian 9.
New network interface names
Debian 8 users are familiar with network interface names such as eth0 for Ethernet and wlan0 for wireless. To fix the problem of enumeration race conditions in previous releases, Debian 9 adopts a new naming scheme based on firmware/BIOS index numbers and PCI card slot numbers.
You will see interface names such as enp3s0 for Ethernet and wlp2s0 for wireless. Note that the new naming scheme takes effect only for new installs; if you upgrade from 8 to 9, the old naming scheme remains in effect.
Run X as non-root user
Prior to Debian 9, the Xorg server must be run as root. The root status potentially exposes the system to the risk of privilege escalation in the event of a bug or a breach. Debian 9 makes possible the running of Xorg server as a non-privileged user. The caveat is that only the gdm3 display manager supports this feature.
net-tools is deprecated
By default, the net-tools package is no longer part of new Debian 9 installs. However, Debian upgrades from release 8 are exempted. Without net-tools, you cannot execute the familiar ifconfig/route/arp/netstat commands, unless you first manually install the deprecated package.
Instead, you are encouraged to use the newer ip command from the iproute2 package which by default is installed.
2. Before you upgrade
Upgrading a Debian system without a proper backup is like walking a tightrope with no security harness: it can be done but the consequences can be disastrous. The following are the types of files that you should consider for backup purposes:
It is critical to back up all databases and critical flat data files before upgrading the system. As mentioned above, MySQL databases will be automatically converted to MariaDB during the upgrade process.You can use the mysqldump command to export a MySQL database into a text file containing the SQL statements necessary to recreate the database.
The resultant SQL files as well as other flat data files can be compressed and backed up using a combination of the tar, gzip, rsync or git commands.
Upgrades to software are usually accompanied by changes in the corresponding software configuration files. You should back up the old configuration files so that you can refer to them to resolve any incompatibility issue that may arise. System configuration files are stored mainly in /etc.
User-specific configuration files are typically stored under the respective user’s home directory (/home). Configuration files are text files, and therefore can be backed up using the same tools as for text data files.
Finally, backups should not be stored on a local disk drive. Good locations for a backup include an external disk drive, a remote computer, and cloud storage.
3. Upgrade step-by-step
Bring existing Debian 8 up to date
It is recommended that you bring Debian 8 up to date before the upgrade to Debian 9. As root, execute the following commands:
# apt-get update # apt-get upgrade
Upgrading your existing release is normally a straightforward procedure. However, occasionally, you may see in the output message that one or more packages “have been kept back.” This means that the package(s) in question cannot be upgraded because a new dependency requires the install of a new package or the removal of an existing package.
To resolve the above issue, execute the following command:
# apt-get dist-upgrade
If the upgrade involves a kernel update, you should reboot the machine before proceeding.
The /etc/apt/sources.list file specifies the sources, including the distribution, from which packages can be downloaded. The distribution can be specified using the Debian codename (“stretch” vs “jessie”) or the release status (“stable” vs “oldstable”).
To upgrade from Debian 8 (“jessie”) to Debian 9 (“stretch”), replace all occurrences of “jessie” in the file to “stretch”.For instance, your old file may resemble the following:
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free deb http://security.debian.org/ jessie/updates main contrib non-free deb http://ftp.us.debian.org/debian/ jessie-updates main contrib non-free
Note that the repository URL will most likely look different in your own /etc/apt/sources.list file. In addition, if your old file references “stable” rather than the explicit codename (“jessie”), you can optionally keep it unchanged (because the current stable release is “stretch”).
However, it is a good practice to explicitly state the codename to ensure that your system will not upgrade unintentionally when a newer stable release is made available.
The new file should look like the following:
deb http://ftp.us.debian.org/debian/ stretch main contrib non-free deb http://security.debian.org/ stretch/updates main contrib non-free deb http://ftp.us.debian.org/debian/ stretch-updates main contrib non-free
Run update after editing the file.
# apt-get update
Verify disk space requirement
Prior to the actual upgrade, do a dry-run to find out the additional disk space required:
# apt-get -o APT::Get::Trivial-Only=true dist-upgrade
Look for the following line at the end of the output:
“After this operation, XXXX MB of additional disk space will be used.”
You should make sure that the machine has sufficient disk space before starting the actual upgrade. To check the amount of disk space currently available, run:
# df -h
Run Debian 9 upgrade.
Execute the following 2 commands in order.
# apt-get upgrade # apt-get dist-upgrade
During the upgrade, you may be prompted to resolve any configuration file conflict. A conflict happens when the installer notices that you have previously edited the configuration file which it is trying to update.
Before you make a decision of which version to use, you can choose to view the differences between your latest edited version and the version to be installed. If you cannot decide on the spot which version to use, you can select to keep your latest edited version, and manually reconcile the differences later.
Upgrade from Debian 8 to Debian 9 involves kernel updates. As a result, you should reboot the machine after the upgrade.
After the reboot, you can verify that the machine indeed runs Debian 9 by executing the following command.
# lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 9.2 (stretch) Release: 9.2 Codename: stretch