Site icon IT Blog

Upgrading Ubuntu 22.04 to 24.04 using the do-release-upgrade command

Ubuntu Server was installed on version 18.04 LTS, but I needed to upgrade it to the latest version. Therefore, I had to upgrade in several stages: 18.04 > 20.04 > 22.04 > 24.04.

The update process is essentially the same for all versions of Ubuntu. First, update the current system and reboot the server:

sudo apt update
sudo apt dist-upgrade
sudo apt autoremove
reboot

When updating via SSH, an additional process is launched on TCP port 1022 just in case, so let’s open it in the firewall beforehand:

iptables -I INPUT -p tcp --dport 1022 -j ACCEPT

Then be sure to open Screen, in case the network connection to the server is broken. I also had cases where there was an update error with some services and the connection was immediately broken. Thanks to Screen, I was able to reconnect and continue the update:

screen -S upgrade

While in screen, run the main update command:

do-release-upgrade

If you have a lot of configuration, you’ll be asked repeatedly during the update whether to replace configuration files. By default, default=N means don’t replace them. So, when you see this, simply press Enter. If there are no important settings in the specified file, select Y to overwrite them with the new version.

Once completed, we’ll agree to reboot the server.
I also needed to find and remove old PHP versions and their configurations, as they were preventing the web server from starting:

dpkg -l | grep php | awk '{print $2}'
apt purge php7.2*
apt purge php7.4*

See also my articles:
Upgrading Ubuntu 14.04 to 16.04
Upgrading Ubuntu 20.04 to 22.04

Exit mobile version