How to upgrade your home computer from Debian 8 (Jessie) to Debian 9 (Stretch)

botond published 2019. 02. 04., h - 01:30 time

Content

 

Introductory

It must be familiar when our computer, which has been up and running for a long time, is ready to upgrade to a major version. In such cases, one is in a dilemma as to whether to embark on a possible reinstallation, then postpone the idea of ​​the installation with a reconfiguration of all programs or the idea of ​​"it will be good for a while anyway".

Well, the good news is that Linux operating systems do not need to be reinstalled, as it is possible to upgrade the main version on the fly, after which we can use everything the same as before.

In this tutorial, I'm going to upgrade from a Debian 8 (Jessie) system to a Debian 9 (Stretch) using a generic home-based laptop.

 

 

What's New in Debian 9 (Stretch)

Before embarking on anything, it's a good idea to be aware of what's new in Debian 9 (Jessie). When installing a fresh Debian 9 (Stretch) system, they don't matter as much, because "it's" just the functionality of a new, empty system where there's not much to lose. However, in the case of an upgrade from "live" Debian 8 (Jessie) in use, the situation is different, because here we can already fail our existing system if we are unprepared for it.

A A lot changes in Debian's 9 version, so we need to be prepared for that. Therefore, it is definitely worth going through these changes so that everyone can highlight the crucial parts that they will have to deal with during and after the update.

 

Backup

The security of our data and the work we do with a lot of work is paramount, so it is important to back up your data if anything goes wrong.

It is advisable to / Etc start with a directory that contains the system settings, config files. This is most easily done with tar command to wrap it as root:

tar -pcvzf /home/<felhasználónevünk>/etc_backup.tar.gz /etc

For example, where you specify your home directory and the name of the archive file you want to create, followed by / Etc directory.

The switch parameters mean:

  • p: (preserve-permissions) Retains information about file permissions.
  • c: Create a new archive
  • v: Verbose mode. This switch will display all packed files. This is how we see what is happening.
  • z: The compiled tar file is finally compressed with gzip.
  • f: Output filename. Wraps in this. This should immediately follow the -f option.

We can use the same procedure to package even our other major libraries that we deem necessary.

If we run a server on the machine, for example mySQLthen save the entire database structure, which by default is a / Var / lib / MySQL is in a library. It contains binary files for all databases, so you don't have to bother exporting the databases separately. Of course, if someone is very accurate, they can be dumped separately or even one at a time. This will be explained in more detail in another description.

We then place the compressed backup files in a secure location, possibly on an external drive, etc.

 

Updating and preparing the current system

IMPORTANT!
If you are upgrading a machine with a graphical interface / desktop environment, it is highly recommended that you complete the entire upgrade process from the text-mode console, such as a desktop. the CTRL + ALT + F1 keystroke or from an external machine SSHconnected from a terminal. This is because during the update process, if the components of the graphical interface are also updated (and are updated), the system may restart the window manager, which means that it also fires the graphical terminal, so we can lose full control of the update process, in the worst case and even the update may be interrupted. Therefore, it is recommended to do the rest outside the graphical interface.

Let's first upgrade to APT luggage database and our packages:

Update: 2019-03-30:
Debian relocated Debian 2019 (Jessie) to non-LTS on March 20, 8 luggage racks to the archive of archive.debian.org, so the jessie-updates and jessie-backports repositories can no longer be updated from regular Debian mirrors.
Learn how to configure the libraries here. (new window)
Once you have made the necessary changes, you can continue to upgrade as usual without any errors apt-get commands:
apt-get update
apt-get upgrade

Then we need to keep in mind a logical rule that the fewer programs installed on the machine, the better our chances of a flawless upgrade. So in the next step, we need to check our existing packages to see if there are any of them that have been installed from a 3rd party package or are obsolete, unsupported packages, and so on.

Find and remove obsolete packages

The easiest way to find outdated or unofficial packages is with the following command:

aptitude search '~o'

If the command does not list any packages, it is best. If, on the other hand, you list some, they are either no longer included in that package repository, have been considered obsolete, or have not been installed from standard Debian repositories (for example, they have been installed from a third-party repository or compiled from source). So if you release one or more items here, consider removing them manually as well from the APT package manager source list (/ Etc / apt / sources.list file) (s). Once the upgrade is complete, we can re-install them if they still exist for Debian 9. If you do not want to uninstall the software listed here because, for example, it is an integral part of your system, such as dependencies on other programs, etc., then check for whether it still exists in Debian 9, has been updated, and so on.

If we had to remove the libraries, or modify the / Etc / apt / sources.list file, run the update commands as root again:

apt-get update
apt-get upgrade

Complete update of current distribution

Next, run the full (still current Jessie) distribution update, which updates packages and dependencies more deeply, to catch up with the future upgrades of Debian 9 (Stretch) packages:

apt-get dist-upgrade

In the meantime, I've made some of these mistakes:

E: Sikertelen letöltés: http://ftp.hu.debian.org/debian/pool/main/p/python-urllib3/python-urllib3_1.9.1-3_all.deb  Nem lehet kapcsolódni ehhez: ftp.hu.debian.org: 80 (195.228.252.133). - connect (111: Kapcsolat elutasítva)

And the update stopped.

If this were to happen in any other case, you shouldn't be scared, just the used Debian mirror might have been overloaded, etc., so you rejected the connection. In this case, after a short wait, run the last command again:

apt-get dist-upgrade

And for the second time, he has nicely updated the entire Jessie distribution to the latest packages and their dependencies. For me, it updated 275 Mb more packages on my laptop after the smooth upgrade ...

Search for broken or withheld packages

Then we do another check for broken or withheld packages:

dpkg --audit
dpkg --get-selections | grep hold

About the dpkg command switches here you can find out.

If we have broken packages, we need to repair them first before we can go any further. A good way to get started is to run apt-get with the clean option:

apt-get clean
apt-get update

If we don't have broken or withheld packages, we can go to the next point.

Modify the list of libraries for Stretch

Open the sources.list file:

nano /etc/apt/sources.list

For me, with a standard Debian 8 (and an 32 bit laptop) installed, it looks like this, with only the factory default luggage options:

# 

# deb cdrom:[Debian GNU/Linux 8 _Jessie_ - Official Snapshot i386 LIVE/INSTALL Binary 20170723-13:21]/ jessie main

deb http://ftp.hu.debian.org/debian/ jessie main
deb-src http://ftp.hu.debian.org/debian/ jessie main

deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

# jessie-updates, previously known as 'volatile'
deb http://ftp.hu.debian.org/debian/ jessie-updates main
deb-src http://ftp.hu.debian.org/debian/ jessie-updates main

Write each "jessie" part of the file into a "stretch" in each line where it appears.

Update: 2019-03-30:
As a result of the reorganization of the aforementioned 2019 March 20 repositories mentioned above, the contents of the original source list file mentioned here are now obsolete and need to be modified. You can find a detailed description here.
So let's make the following change with this in mind!
This change does not affect the Debian 9 (Stretch) package repositories, so the following changes to Stretch in this description are equally valid (I left the original parts to keep track of the change).

Then my file looks like this:

# 

# deb cdrom:[Debian GNU/Linux 8 _Jessie_ - Official Snapshot i386 LIVE/INSTALL Binary 20170723-13:21]/ jessie main

deb http://ftp.hu.debian.org/debian/ stretch main
deb-src http://ftp.hu.debian.org/debian/ stretch main

deb http://security.debian.org/ stretch/updates main
deb-src http://security.debian.org/ stretch/updates main

# stretch-updates, previously known as 'volatile'
deb http://ftp.hu.debian.org/debian/ stretch-updates main
deb-src http://ftp.hu.debian.org/debian/ stretch-updates main

So no matter what Debian mirrors, repositories and sections are configured, the point is that we have previously removed all unofficial Debian repositories, so that only the official ones have to be redone here, with just the distribution code name "jessie" from stretch to stretch.

Then update it JUST luggage database:

apt-get update

Simulation of libraries upgrade

Then we run a simulation to check if all packages installed from the libraries can be updated:

apt list --upgradable

Here we get a very long list of output, with packet names normally highlighted in green at the beginning of the rows, followed by the versions in the new distribution, and then upgraded and from which current version:

Run a Debian APT package manager simulation

Because this list is awfully long, and the terminal window on the other machine I'm logged in to over SSH doesn't let me roll back, so I can't see it all, so I even get an error code from echo $? command, which returns the result of running the last command. Here you get 0 results, so there is no error in my package list, so the system can be upgraded.

 

 

Upgrading your system to Debian 9 (Stretch)

If we got this far without error, all that was left was to upgrade the distribution to the new Stretch release. Since the delicate part of this is coming, if we haven’t left the graphical interface of the machine to be upgraded yet, let’s do it now, as I wrote above, to avoid losing the connection with our upgrade process due to restarting services.

Updating basic packages

First, issue the standard "smooth" upgrade command to first upgrade the basic packages:

apt-get upgrade

All I have to do now is upgrade 763 and write that you do not need to update 487:

Run Debian APT upgrade command with new libraries

Of course, this is a relatively recent and little-used installation, so with an older system that has been "worn out" for a long time, we can expect much more package upgrades than that.

Press I for this question, and then wait for it to run, while keeping an eye on what's going on.

In the meantime, you can enter different help files for each package, scroll through them, and then write what you can exit (for example, the letter Q).

He finished with me after a good half hour of rolling. Well, it wasn't a standard upgrade operation, that's for sure. He wrote a warning in one or two places that the / etc / ... subdirectory could not be deleted because it was not empty. Well, damn it ... 

Complete distribution update

Then, here's a full distribution update:

apt-get dist-upgrade

Here you will also list the remaining packages to upgrade and ask if you can go. Again, yes.

Here, too, at the beginning of downloading packages, you may get stuck and unable to connect to the home mirror. In this case, if it stops completely, run the command again and continue to download the packages where you left off.

It is likely that there may be bandwidth or traffic limitations on the servers of the repositories, which allow only X amounts of data to be downloaded per unit of time so that each connection / installation cannot overload their resources. Tell me so far only the http://ftp.hu.debian.org dumped me with the following error message:

Nem lehet csatlakozni ehhez: ftp.hu.debian.org:http:

E: Nem lehet letölteni néhány archívumot. Próbálja futtatni az „apt-get update” parancsot, vagy használja a --fix-missing kapcsolót.

But after a short wait, rerun the dist-upgrade command, (not what you suggest in the error message) and continue the download nicely.

So, if you choose a larger, foreign mirror at the very beginning of the installation (or overwrite them in the sources.list file), this problem no longer exists.

After downloading the packages, you are only working locally on the machine, so there is no such connection problem.

It is advisable to keep an eye on the events while sitting in front of the machine, as during the installation and configuration of the packages there may be some dialogs that need to be executed or a setup question answered. For example:

Debian Update - Package Configuration

You will then be asked if we will allow you to automatically restart the required services during the upgrade process:

Debian Update - Package Configuration - Restart Services Automatically

Then press Yes, because they still need to be restarted.

Here too, it will take a long time to install the packages for the new distribution, so you should be patient to check for errors, etc.

 

Restart the machine and check for an update

When all is done, restart your machine:

reboot

Then, after the system is booted, we will see a striking change.

Pre-upgrade table:

Debian 8 (Jessie) - Old table

And now, after the reboot:

Debian 9 (Stretch) - New table

So at first it seems that a lot of work made sense. Poor Debian even had time to exchange the desktop wallpaper for us. : D

Now let's check things in the background.

Kernel and check release information

Let's check the kernel:

uname -r

To do this, you need to release this starting version: 4.9.0. [...]

Check your release information:

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Version and package verification

To read the Debian version:

cat /etc/debian_version

It prints 9.7 for this. This is also good.

Let's look for obsolete packages as we did before the upgrade:

aptitude search '~o'

Here I publish a long list. There is nothing wrong with this, as many old packages from Debian 8 have been deprecated. So if there are others, we need to arrange them now.

Manage obsolete packages

Deprecated packages can continue to be used when needed, but are no longer supported by Debian, so for security reasons, they should no longer be used Source.

Let's go through this list and if we don't find what's needed in these packages, we'll delete them.

Expand the list command above with an awk filtering that only returns the package names to us in the list 3. from column:

aptitude search '~o' | awk '$4 == "-" {print $3; next}; {print $2}'

Redirect this to a file:

aptitude search '~o' | awk '$4 == "-" {print $3; next}; {print $2}' > elavult_csomagok.txt

If there are packages that we want to keep anyway, then edit our file eg. the dwarf-with:

nano elavult_csomagok.txt

And remove the packages you want to keep from the list in the file and save the file.

Be careful here, for example, if you have previously used a self-compiled package for something and it is included, it is advisable to remove it from this list of packages to be deleted, as it would not be updated anyway, but the package is still in use. So here we have to select according to our own situation.
Update: 2019-03-30:
Following the package changes mentioned above, the system can also consider packages that have already been moved to the archived mirror and are no longer updated. So now be even more careful not to accidentally take out packages that are still in use!

Next, issue the package delete command by specifying the following list file:

apt-get --purge remove $(cat elavult_csomagok.txt)

It then lists the packages and then prints out the usual package statistics and asks if the deletion can go. For example, I have:

[...]
0 frissített, 0 újonnan telepített, 117 eltávolítandó és 0 nem frissített.
A művelet után 814 MB lemezterület szabadul fel.
Folytatni akarja? [I/n]

Press Yes to download these packages and delete the associated configuration and configuration files. For example, it also reconfigures Grub after the old kernel files have been removed. So it does a complete cleanup so there is no unused stuff left in the system.

 

 

Conclusion

Again, it wasn't compromised in the power of Linux and Debian in particular, as such a major major upgrade was done nicely, after which we got a fresh Debian 9 (Stretch) operating system that will continue to do its job with rock solid stability and solve tasks entrusted to it.

My plans are to upgrade this server to Debian 9 in the same way. However, this will be an even tougher task as the server runs web services and several live websites serve its lost visitors. Therefore, as a follow-up to this description, a Debian 8 (Jessie) is the perfect 1.1 server I will do the upgrade with the clone of version XNUMX, so that everything will go perfectly there as well, before I do it live. I will also make another description of this, in which I will share my experiences and information related to the updates of things on the server.