Downgrade Ubuntu to previous version? [100% Working]


Ubuntu

Author: Omer Cakmak
Reviewer: Deepak Prasad

Ubuntu releases receive a development codename ("Kinetic Kudu") and are organized by release year and month. For example, Ubuntu 22.10 was released in October 2022, and 21.04 (Hirsute Hippo) was released in April 2011.

LTS or "Long Term Support" versions are released every two years in April. LTS releases are "enterprise grade" versions of Ubuntu, with 95% of them being LTS releases.

A temporary version of Ubuntu is released every six months between LTS releases, and the latest example is 22.10. These are production quality releases and are supported for 9 months, providing enough time for users to update. These releases do not take the long-term commitment of LTS releases.

There are 3 different version commits in Ubuntu:

  • Hardware and maintenance updates
  • Interim release Standard Support
  • Extended Security Maintenance (ESM)

In this article, we will explain the steps to downgrade from Ubuntu 21.04 to 20.04 released with the Interim release Standard Support.

 

How to downgrade Ubuntu 21.04 to 20.04?

IMPORTANT NOTE:
It is recommended to take backup of your existing data to avoid any unforeseen events. Please test the steps in lab environment before trying it out in production.

Sometimes the upgrade is done on purpose, sometimes the operating system is upgraded unconsciously. In this case, downgrade is required if there is no new LTS version.

As in version upgrade, root authorized user should be used in version downgrade or operations should be performed with sudo.

foc@foc-ubuntu21:~$ sudo su
[sudo] password for foc:
root@foc-ubuntu21:/home/foc#

Current version information:

root@foc-ubuntu21:/home/foc# cat /etc/os-release
NAME="Ubuntu"
VERSION="21.04 (Hirsute Hippo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 21.04"
VERSION_ID="21.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=hirsute
UBUNTU_CODENAME=hirsute

Current kernel information:

root@foc-ubuntu21:/home/foc# uname -a
Linux foc-ubuntu21 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Current repository information:

root@foc-ubuntu21:/# grep -wv "#" /etc/apt/sources.list

#deb cdrom:[Ubuntu 21.04 _Hirsute Hippo_ - Release amd64 (20210420)]/ hirsute main restricted
deb http://us.archive.ubuntu.com/ubuntu/ hirsute main restricted
deb http://us.archive.ubuntu.com/ubuntu/ hirsute-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ hirsute universe
deb http://us.archive.ubuntu.com/ubuntu/ hirsute-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ hirsute multiverse
deb http://us.archive.ubuntu.com/ubuntu/ hirsute-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ hirsute-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu hirsute-security main restricted
deb http://security.ubuntu.com/ubuntu hirsute-security universe
deb http://security.ubuntu.com/ubuntu hirsute-security multiverse

If you cannot get updates with the current repository, edit the sources.list file with the following command:

root@foc-ubuntu21:/ sed -i -e 's/us.archive/old-releases/g' /etc/apt/sources.list

Then update the package list and get an upgrade:

root@foc-ubuntu21:/ apt update -y &&  apt upgrade -y

We are no longer dealing with the previous version. Actions after this step include downgrading.

 

Step-1: Backup the old sources.list file

Back up the old sources.list file with the following commands:

root@foc-ubuntu21:~# cd /etc/apt/
root@foc-ubuntu21:/etc/apt# mv sources.list sources.list-old

 

Step-2: Add Ubuntu 20.04 LTS (Focal Fossa) repository

Now add the official Ubuntu 20.04 LTS (Focal Fossa) repository information:

root@foc-ubuntu21:/etc/apt# nano sources.list

deb http://tr.archive.ubuntu.com/ubuntu focal main restricted
#deb-src http://tr.archive.ubuntu.com/ubuntu focal main restricted
deb http://tr.archive.ubuntu.com/ubuntu focal-updates main restricted
#deb-src http://tr.archive.ubuntu.com/ubuntu focal-updates main restricted
deb http://tr.archive.ubuntu.com/ubuntu focal universe
#deb-src http://tr.archive.ubuntu.com/ubuntu focal universe
deb http://tr.archive.ubuntu.com/ubuntu focal-updates universe
#deb-src http://tr.archive.ubuntu.com/ubuntu focal-updates universe
deb http://tr.archive.ubuntu.com/ubuntu focal multiverse
#deb-src http://tr.archive.ubuntu.com/ubuntu focal multiverse
deb http://tr.archive.ubuntu.com/ubuntu focal-updates multiverse
#deb-src http://tr.archive.ubuntu.com/ubuntu focal-updates multiverse
deb http://tr.archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
#deb-src http://tr.archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
deb http://tr.archive.ubuntu.com/ubuntu focal-security main restricted
#deb-src http://tr.archive.ubuntu.com/ubuntu focal-security main restricted
deb http://tr.archive.ubuntu.com/ubuntu focal-security universe
#deb-src http://tr.archive.ubuntu.com/ubuntu focal-security universe
deb http://tr.archive.ubuntu.com/ubuntu focal-security multiverse
#deb-src http://tr.archive.ubuntu.com/ubuntu focal-security multiverse

 

Step-3: Create preferences file

The part files /etc/apt/preferences.d/ in the APT preferences file can be used to control which package versions are selected for installation.
APT assigns a priority to each available version, and subject to dependency restrictions, apt-get selects the version with the highest priority for installation.
APT preferences override the priorities that APT assigns to package versions by default, thus giving the user control over which one is selected for installation.

Create a file for focal under the /etc/apt/preferences.d directory and write the following information:

root@foc-ubuntu21:/etc/apt# nano /etc/apt/preferences.d/focal

Package: *
Pin: release n=focal
Pin-Priority: 1001

Package: *
Pin: release n=focal-updates
Pin-Priority: 1002

Package: *
Pin: release n=focal-security
Pin-Priority: 1003

 

Step-4: Start Downgrade

Now we start downgrading with the new repository:

root@foc-ubuntu21:/etc/apt# apt update -y

Install the aptitude package for downgrade:

root@foc-ubuntu21:/etc/apt# apt install aptitude -y

Then start the downgrade:

root@foc-ubuntu21:/etc/apt# aptitude dist-upgrade -y

During the downgrade, the downgrade process may be interrupted:

...
Processing triggers for libgdk-pixbuf-2.0-0:amd64 (2.42.2+dfsg-1build1) ...
Errors were encountered while processing:
cups-ipp-utils
systemd-sysv
gir1.2-freedesktop:amd64
gir1.2-gtk-3.0:amd64
cups-filters-core-drivers
libcupsimage2:amd64
gir1.2-pango-1.0:amd64
gir1.2-gnomedesktop-3.0:amd64
gnome-shell
ubuntu-session
gdm3
libpam-systemd:amd64
cups-filters
gir1.2-vte-2.91:amd64
gir1.2-gnomebluetooth-1.0:amd64
xserver-xorg-legacy
gnome-settings-daemon
gjs
dbus-user-session
printer-driver-foo2zjs
cups

Current status: 8 (+8) broken, 47 (-2) upgradable.

In this case, the downgrade process is repeated:

root@foc-ubuntu21:/etc/apt# aptitude dist-upgrade -y

Fix bad packages in package downgrade with the following command:

root@foc-ubuntu21:/etc/apt# apt --fix-broken install

Depending on the packages installed on Ubuntu 21.04 and their dependencies, you may receive errors in the installation. Here is an example error and its solution:

dpkg: error processing archive /var/cache/apt/archives/libgamemode0_1.5.
1-0ubuntu3.1_amd64.deb (--unpack):
trying to overwrite '/usr/libexec/cpugovctl', which is also in package
gamemode-daemon 1.6.1-1

Solution:

root@foc-ubuntu21:/etc/apt# dpkg -i --force-overwrite /var/cache/apt/archives/libgamemode0_1.5.1-0ubuntu3.1_amd64.deb

Then the downgrade process is repeated:

root@foc-ubuntu21:/etc/apt# aptitude dist-upgrade -y

The downgrade continues until you see the following message:

No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

Downgrade completed successfully, release version:

root@foc-ubuntu21:/etc/apt# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

The operating system became Ubuntu 20.04.5 LTS (Focal Fossa).

 

Step-5: Delete unnecessary packages

Finally after installation the unused packages are deleted:

root@foc-ubuntu21:/etc/apt# apt autoremove -y

 

Summary

Upgrade is a difficult process, but downgrade is more difficult. If you want to downgrade your Ubuntu 21.04 operating system to 20.04, this article will do the trick. But you should know that you will encounter errors and problems.

Reinstallation is recommended if possible.

 

References

askubuntu.com - How to roll back Ubuntu to a previous version?
askubuntu.com - dpkg: error processing

 

Omer Cakmak

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

11 thoughts on “Downgrade Ubuntu to previous version? [100% Working]”

  1. I followed the instructions to downgrade from 24.10 to 2
    4.04 after many apps started crashing with 24.10 that worked fine with 24.04. However, after following the instructions, I lost internet connection with both wifi and Ethernet disabled. Also, gui and many other apps are not functional. I tried to get back 24.10 with backed up file, and that is also not working. Any fix in addressing this problem?

    Reply
  2. For raspberry 4, LTS 22 to LTS 20 some changes are needed:

    ...
    
    ~$ vim sources.list
    ~$ cat sources.list
    deb http://ports.ubuntu.com/ubuntu-ports focal main restricted
    deb http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted
    deb http://ports.ubuntu.com/ubuntu-ports focal universe
    deb http://ports.ubuntu.com/ubuntu-ports focal-updates universe
    deb http://ports.ubuntu.com/ubuntu-ports focal multiverse
    deb http://ports.ubuntu.com/ubuntu-ports focal-updates multiverse
    deb http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse
    deb http://ports.ubuntu.com/ubuntu-ports focal-security main restricted
    deb http://ports.ubuntu.com/ubuntu-ports focal-security universe
    deb http://ports.ubuntu.com/ubuntu-ports focal-security multiverse
    deb [arch=arm64] http://ports.ubuntu.com/ focal main multiverse universe
    deb [arch=arm64] http://ports.ubuntu.com/ focal-security main multiverse universe
    deb [arch=arm64] http://ports.ubuntu.com/ focal-backports main multiverse universe
    deb [arch=arm64] http://ports.ubuntu.com/ focal-updates main multiverse universe
    
    ubuntu@rp42:~$ apt update
    
    ubuntu@rp42:~$ vim /etc/apt/preferences.d/focal
    ubuntu@rp42:~$ cat /etc/apt/preferences.d/focal
    Package: *
    Pin: release n=focal
    Pin-Priority: 1001
    
    Package: *
    Pin: release n=focal-updates
    Pin-Priority: 1002
    
    Package: *
    Pin: release n=focal-security
    Pin-Priority: 1003
    
    
    ubuntu@rp42:~$ apt update -y
    
    ubuntu@rp42:~$ apt install aptitude -y --allow-downgrades
    
    -> reboot
    
    ubuntu@rp42:~$ aptitude dist-upgrade -y
    
    ubuntu@rp42:~$ aptitude dist-upgrade -y
    
    ubuntu@rp42:~$ apt autoclean
    
    -> reboot
    
    ---

    I had no issues at all. Only needed to repeat dist-upgrade twice.

    Thank you!

    Reply
  3. A great thank you.
    The last Ubuntu (23.04) crashed my laptop, and I was able to downgrade to 22.10 which worked.
    You gave me a way to avoid nightmares… and reinstall from scratch.
    Thanks a lot

    Reply
  4. how do you install Ubuntu desktop?
    I can’t get the ip or internet connection after downgrade.
    ifconfig only shows the “lo” entry.

    Reply
  5. I used this for 22 to 20. Worked like a charm. Also had a few panic moments when booting again was a bit longer then expected.

    10/10 would attempt to brick a server again.

    Reply
  6. This is doe af, I lost a few stuff though but it was great. And I had a mini scare when I lost my Ubuntu desktop while downgrading… but you just need to continue the downgrade and reinstall the Ubuntu desktop when you have finished the downgrade. PS have this article opened somewhere els

    Reply
    • Hi Beth,

      If you could tell me how to install Ubuntu Desktop after downgrading, it will be helpful. I can’t get the ip or internet connection after downgrade.can’t able to download anything using apt

      Reply

Leave a Comment