• server
  • hacker
  • matrix
  • robot
  • web

Server Upgrade Ubuntu Bionic 18.04 to Focal 20.04

Written by Mike Ennulat. Posted in Server-en

It's time again. The LTS version of Ubuntu Server 18.04 Bionic receives a system upgrade to LTS 20.04 Focal Fossa. There is no reason to upgrade yet. 18.04 is an LTS version and therefore it will continue to be supplied with system and security updates. In principle, a productive system should not be upgraded prior 20.04.1 version, as a number of bugs will still be fixed by then. This version usually appears about 3 months after publication of 20.04, most probably around mid-July. You can also see this as soon as you try to update:

sudo do-release-upgrade
Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS develoment release 
set Prompt=normal in /etc/update-manager/release-upgrades.

But of course we can force an upgrade. This should also work if the server is already running on 19.10 Eoan.

Backup

The first thing to do is, as always, to do a complete backup of your important data. My server is setted up following the excellent tutorial on HowToForge. To back the most important data:

/* Backup important data */ 
sudo -s cd /root tar -pczf ./completesystembackup.tar.gz /etc/letsencrypt /home/USER-DIRECTORY /var/vmail /var/log /var/www /etc/cron.d /etc/apache2 /etc/bind /usr/local/ispconfig/interface/lib /usr/local/ispconfig/server/lib /etc/postfix /etc/dovecot /etc/php* 
/* Database Backup */ 
mysqldump -u root -pPASSWORD --all-databases > all-database.sql 
/* Backup of Configuration in /etc */
tar -pczf ./backup-etc.tar.gz /etc 

 Keep these files in a safe place (Download / different disk aso..)

System Update

sudo apt update
sudo apt upgrade
sudo apt dist-upgrade

Restart your server:

sudo reboot

After you have reconnected to the server via SSH, I strongly recommend if necessary to install and run Screen. If the connection is interrupted, you may continue with the upgrade after reconnecting:

sudo apt install screen
screen

After a disconnect, log in again with SSH and execute:

screen -x

Release Upgrade

I prefer the manual upgrade method. If you prefer to work with Ubuntu Update Manager, click here: Ubuntu Update Manager. If you haven't already done so, you should immediately update PHP to 7.4 prior system upgrade, as Focal is running PHP 7.4. The Upgrade might break as Apache tries to start a non existant PHP 7.2!!. 

First of all, the package sources need to be adjusted:

sudo sed -i 's/bionic/focal/g' /etc/apt/sources.list

Or if the server is running EOAN:

sudo sed -i 's/eoan/focal/g' /etc/apt/sources.list

All files in the /etc/apt/sources.list.d/ directory must also be edited accordingly. As an example, I had to edit the ondrej-ubuntu-php-bionic.list because I have different PHP versions on the server. Simply change the file bionic / eoan to focal and save it under a new name. Delete the old bionic list afterwards. Now we start the upgrade:

sudo apt update
sudo apt upgrade
sudo apt dist-upgrade

Continue: click here

 

Ubuntu Update Manager:

sudo apt install update-manager-core
sudo do-release-upgrade

If there is no release candidate yet, install the development version:

sudo do-release-upgrade -d

Shortly afterwards you will be asked if you would like to continue and to start a new SSH server on port 1022. Thus, if the normal SSH server is no longer accessible, you can continue your upgrade. May be you have to open port 1022 in your firewall.

ubuntu upgrade 1

After confirmation the upgrade process begins. You will be asked again if you really want to upgrade.

ubuntu upgrade 2If you confirm with "y", the upgrade process cannot be canceled. 

The download took about 30 seconds and the upgrade process around 30 minutes on my server. After downloading the updates, there is a question that you may answer with "Yes":

ubuntu upgrade 3

Apt listchanges can be closed with q after reading. When asked whether the configuration file should be replaced, always answer with N (default). At one time you might see the update of LXD, stating waiting for restart after you confirmed OK:

ubuntu upgrade 4

Keep calm. No intervention is necessary, it continues after a few minutes. The process is completed after you are back on the prompt.

Since Ispconfig is known to have problems with Apparmor, it must be removed after the upgrade. This also uninstalls LXD and the Snap Daemon.

sudo service apparmor stop
sudo update-rc.d -f apparmor remove 
sudo apt-get purge apparmor apparmor-utils

Finally reboot, update again and delete unnecessary files:

sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
sudo apt autoclean

Now the correct Ubuntu version should be displayed after the lsb_release command:

lsb_release -a
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04 LTS
Release:	20.04
Codename:	focal

 

Tags: servers server ubuntu upgrade release-upgrade focal bionic eoan system update