Upgrade Ubuntu 20.04 to 22.04

This manual will guide you through the upgrade from "Ubuntu 20.04 LTS (Focal Fossa)" to the latest Long Term Support (LTS) version of the Ubuntu operating system, Ubuntu 22.04 (Jammy Jellyfish). This was released on April 21, 2022

Before starting the tutorial, do you not have a Cloud server with Ubuntu 20.04 or do you prefer a Cloud server already updated to Ubuntu 22.04? Don't worry! With just one click, you can easily deploy it with SW Hosting.

cta:cloud_so_ubuntu_20

cta:cloud_so_ubuntu_22

From SW Hosting, in order to always provide knowledge and be able to help our customers in different situations and scenarios that may be encountered, we have decided to document the process of upgrading to this version. This way you can enjoy the latest functionalities and software security updates for your operating system.

In the following link you can find more information about the changes offered by this new version: https://discourse.ubuntu.com/t/jammy-jellyfish-release-notes/24668

danger Warning! As with almost any upgrade between "major" versions of an operating system, this process carries an inherent risk of failure, data loss or corrupted software configuration. Full backups and thorough testing are strongly recommended before beginning.

The upgrade process takes time due to Internet speed and other factors. Do not cancel the operation once started, as it will leave your Ubuntu machine in an inconsistent state. SW Hosting is not responsible for failed upgrade procedures or loss of data.

PREVIOUS RECOMMENDATIONS:

Backups

SW Hosting strongly recommends that you have a backup of all your data before upgrading from Ubuntu 20.04 to Ubuntu 22.04. Make sure you have all your backups up to date, so that you can ensure the integrity of all your data before proceeding. https://www.swhosting.com/en/comunidad/manual/activar-copias-de-seguridad-backups-en-mi-cloud

Snapshots

In addition, you also have the possibility to activate the snapshot service of your cloud service through your SWPanel, we recommend you to make a snapshot of your cloud prior to the upgrade process, so you can revert the changes at any time if necessary:

https://www.swhosting.com/en/comunidad/manual/como-crear-y-gestionar-snapshots-de-tu-servidor-cloud

Disk space

Make sure you have enough free disk space before starting this process.

From SW Hosting, we recommend having at least 10 GB of free disk space before upgrading. Use the df command to verify this:

df -h

Third-party repositories

All third-party repositories are commented out (disabled) during the upgrade process of your operating system. If you are using any extra repositories on your server, you will need to enable them after the upgrade procedure is complete. You can find third-party repositories or mirrors in the directory:

/etc/apt/sources.list.d/

Ubuntu 20.04 LTS to 22.04 LTS Upgrade Process

First check the /etc/update-manager/release-upgrades file (required for GUI and CLI methods).

Check the default behavior for the version updater, using the cat / more o less command: less /etc/update-manager/release-upgrades

And make sure that the following line is set to lts: Prompt=lts

Step 1: Find out the Ubuntu Linux kernel version

First it is important to check what version of Kernel you currently have, in case during the upgrade, it is updated as well, and in case it is necessary to reboot your server.

Make a note of the current Linux distribution name and kernel version before you start. Use the "uname" command and the "lsb_release" command as follows:

uname -mrs lsb_release -a

Step 2: Upgrade your system

Open the terminal application. For the remote server, log in with the ssh command. First, look for all packages that are in "hold" mode, type the command apt-mark:

sudo apt-mark showhold

If you see an empty output and there are no packages withheld, you can safely continue. Otherwise, you must remove the package hold with the "apt-mark" command. For example, release the packages as follows (replace package1 package2 with the real names):

sudo apt-mark unhold package1 package2

Then, update the current system using the apt command:

sudo apt update && sudo apt upgrade

You will be shown a list of updates and asked to continue. Press "y" to confirm and press Enter.

This process may take some time. Once finished, use the dist-upgrade command with apt-get which will perform any additional upgrades that involve changing dependencies, adding or removing new packages as needed.

This command will install a set of updates that may have been held back by the previous apt upgrade step:

sudo apt dist-upgrade

Again, answer "y" when prompted to continue and wait for the updates to finish.

If a new Linux kernel is installed, review and compare it to the command provided in the previous step:

uname -mrs

If your Kernel version has changed, reboot your system before continuing:

sudo reboot

Now that you have an updated Ubuntu 20.04 installation, you can use "do-release-upgrade" to upgrade to version 22.04.

Step 3: Open ports

You may need to activate the FW Layer 4 Management via your SWPanel and enable the following access profile temporarily, to open the necessary ports used during the upgrade process of your system:

https://www.swhosting.com/en/comunidad/manual/firewall-perimetral-de-capa-4-gestionable

SWPanel -> Dasboard of your cloud service -> Security (left side Dashboard) -> FW Layer 4 -> Layer 4 Firewall Management --> Security Profile --> All open

enter image description here If you have Ubuntu's UFW software installed, you will have to perform the same procedure and also open the 1022 TCP port, which is used by the software to update:

https://www.swhosting.com/en/comunidad/manual/que-es-el-firewall-ufw-y-como-configurarlo-en-linux

Step 4: Upgrade to 22.04 LTS using the command line:

At the command prompt, type the command "do-release-upgrade" as follows to start the upgrade procedure:

sudo do-release-upgrade

The ssh user will see the message immediately:

Reading cache

Checking package manager

Is it still running under SSH? 

This session appears to be running under ssh. It is not recommended to 
to upgrade via ssh at this time because in case of failure it is more difficult to recover. 
is more difficult to recover from. 

If it continues, an additional ssh daemon will be started on port 
'1022'. 
Do you want to continue? 

Continue [yN] y

Type "y", then you will get another message:

Starting additional sshd 
 
To make recovery in case of failure easier, an additional sshd will 
be started on port '1022'. If anything goes wrong with the running 
ssh you can still connect to the additional one. 
If you run a firewall, you may need to temporarily open this port. As 
this is potentially dangerous it's not done automatically. You can 
open the port with e.g.: 
'iptables -I INPUT -p tcp --dport 1022 -j ACCEPT' 
 
To continue please press [ENTER]

Since we already opened port 1022, press the [Enter] key to continue. Next, you must confirm the "Ubuntu Focal" to "Ubuntu Jammy" upgrade entries: Again, you will get a final prompt with the details as follows:

Do you want to start the upgrade? 

Checking package manager
Reading package lists... Done    
Building dependency tree          
Reading state information... Done

Calculating the changes

Calculating the changes
  MarkInstall libflashrom1:amd64 < none -> 1.2-5build1 @un uN Ib > FU=1
  Installing libftdi1-2 as Depends of libflashrom1
    MarkInstall libftdi1-2:amd64 < none -> 1.5-5build3 @un uN > FU=0

Do you want to start the upgrade? 


4 packages are going to be removed. 90 new packages are going to be 
installed. 565 packages are going to be upgraded. 

You have to download a total of 553 M. This download will take about 
1 minute with your connection. 

Installing the upgrade can take several hours. Once the download has 
finished, the process cannot be canceled. 

 Continue [yN]  Details [d]

Finally press "y" again to accept and continue.

Be sure to also confirm, to restart the services when prompted.

enter image description hereKeep the configuration of your modified files in Ubuntu Linux 20.04 LTS, when upgrading to 22.04 LTS: enter image description here Other examples:

Configuration file '/etc/sysctl.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
 sysctl.conf (Y/I/N/O/D/Z) [default=N] ? 

Press ENTER to check the default option (do not modify)

Dealing with obsolete packages in Ubuntu:
You may possibly be prompted to remove the obsolete package as follows:

Searching for obsolete software
Reading state information... Done

Remove obsolete packages? 


81 packages are going to be removed. 

 Continue [yN]  Details [d]

Press "d" to see details about these packages and then confirm it by pressing "y", or deny it by pressing "N".

The system update is complete

After a while, you will get a confirmation on the screen.

System upgrade is complete.

Restart required 

To finish the upgrade, a restart is required. 
If you select 'y' the system will be restarted. 

Continue [yN]

A reboot is required to finish the upgrade from 20.04 LTS to 22.04.
Be sure to choose "y", and then Ubuntu will reboot.

Afterwards, when restarting, do not forget to delete the rules of your FW layer 4 via your SWPanel, and/or in UFW that you used to open the tcp/1022 port.

Step 5 - Verification

Once the system reboots, you can log in using the GUI or the ssh-based session. Then, you can see the Linux kernel version, run: uname -mrs

Output: Linux 5.15.0-58-generic x86_64

Of course, use the lsb_release command as well: lsb_release -a

Output: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy

Step 6 (Optional) - Enable third-party repositories/mirrors:

Now that the upgrade from Ubuntu 20.04 LTS to 22.04 LTS is complete, if you had additional third-party repositories, you will need to verify that they are re-enabled, or enable them. Otherwise, you will not receive updates from those repositories.

You can check the active additional repositories as follows:

cd /etc/apt/sources.list.d ls -l cat repo-adicional.list

To re-enable it, you should edit the file with a text editor (nano / vi) and uncomment the line by removing the #:

Then run the apt command to update those packages:

sudo apt update sudo apt upgrade

Finally, clean up unwanted and unused leftover packages:

sudo apt autoremove --purge

Remember that if you do not yet have a Cloud server with Ubuntu 20.04 or Ubuntu 22.04 you can easily deploy it with SW Hosting.

cta:cloud_so_ubuntu-20

cta:cloud_so_ubuntu-22


2024 SW Hosting. All rights reserved. The prices shown on the website do not include any applicable taxes.