How to Upgrade Ubuntu 22.04 to 24.04 LTS: A Complete Guide Link: https://www.cyberciti.biz/faq/how-to-upgrade-from-ubuntu-22-04-lts-to-ubuntu-24-04-lts/ Author:   Vivek Gite   Last updated:   September 5, 2024   47  comments U buntu 24.04 LTS (Noble Numbat) was launched on April 25th, 2024. This new version will be supported for five years until June 2029. The armhf architecture now provides support for the Year 2038 problem. The upgrades include significant updates to core packages like Linux kernel, systemd, Netplan, toolchain upgrades for better development support, enhanced security measures, and performance optimizations. It also has an updated GNOME desktop environment and other default applications. Let us see how to upgrade Ubuntu 22.04 LTS to Ubuntu 24.04 LTS using the CLI over ssh-based session. Users of Ubuntu 23.10 will be offered an automatic upgrade to 24.04 shortly after its release. However, users of Ubuntu 22.04 LTS will only receive the automatic upgrade offer once  24.04.1 LTS becomes available, which is scheduled for August 29  . However, you can force an immediate upgrade using the  -d  option and jump from  22.04 to 23.10  and then finally to  24.04 LTS . This is until August 29, 2024. After that date, you can directly jump from 22.04 to 24.04 LTS directly. Tutorial details Difficulty level Intermediate Root privileges Yes Requirements Linux terminal Category Server Upgrade OS compatibility Linux  •  Ubuntu Est. reading time 7 minutes Advertisement   Step 1 – Backup your system Backing up your data before upgrading from Ubuntu 22.04 LTS to 24.04 LTS is vital for two reasons. First, even though thoroughly tested, unexpected issues can arise during the upgrade process. If something goes wrong, a backup ensures you can recover irreplaceable files like databases, code written in PHP/Perl/Python, documents, photos, or scripts. Second, upgrading to a new LTS version might introduce changes that cause some of your data incompatibility. A backup allows you to restore and migrate the data to a format compatible with the new Ubuntu version. Remember to back up your data before upgrading to Ubuntu. Don’t blame us if you lose everything! How do I backup important data or everything? Cloud providers usually offer backup options, such as taking a snapshot of your cloud server (here is guide for  EC2  and  Lightsail VM ). Alternatively, you can use various backup tools like  rsnapshot ,  tarsnap ,  restic ,  kbackup ,  duplicity ,  bacula , and  Déjà Dup . Testing your backups and verifying that they can be restored is necessary, as is finding out how long it takes to restore the data. Step 2 – Update your system Run the  apt command  to upgrade all installed packages on the Ubuntu 22.04 LTS: $  sudo apt update $  sudo apt list --upgradable | more $  sudo apt upgrade Fig.01: Upgrading Ubuntu 22.04 LTS apps and packages to the latest version (click to enlarge) You may see a message like this while patching 22.04 LTS system:   Newer kernel available The currently running kernel version is 5.15.0-1030-aws which is not the expected kernel version 6.5.0-1018-aws. Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. Hence,  reboot the Ubuntu Linux box  using the  reboot  or  shutdown : $  sudo reboot Fig.02: Rebooting the Ubuntu 22.04 LTS machine (click to enlarge) Step 3 – Upgrading from 22.04 LTS or 24.04 LTS You must install ubuntu-release-upgrader-core package: $  sudo apt install ubuntu-release-upgrader-core Ensure the  Prompt  line in /etc/update-manager/release-upgrades is set to ‘ lts ‘ using the “ grep ” or “ cat ” $  grep 'lts' /etc/update-manager/release-upgrades $  cat /etc/update-manager/release-upgrades Fig.03: Checking if the LTS prompt config is set or not on Ubuntu 22.04 LTS (click to enlarge) Opening up TCP port 1022 using the  ufw command  or  iptables command For those using ssh-based sessions, open an additional SSH port using the ufw command, starting at port 1022. This is the default port set by the upgrade procedure as a fallback if the default SSH port dies during upgrades. The syntax for the  ufw command  to  open SSH alternative TCP/1022 port with ufw  is as follows: $  sudo ufw allow 1022/tcp comment 'Open port ssh TCP/1022 as failsafe for upgrades' $  sudo ufw status Here is an example for iptables: $  sudo /sbin/iptables -I INPUT -p tcp --dport 1022 -j ACCEPT Open the TCP/1022 port using your cloud server firewall if you have one. Here is how to do it with the AWS  EC2 security groups  or  Lightsail  instance: Fig. 04: Open the TCP port 1022 using the CLOUD server firewall (click to enlarge) Step 4 – Upgrading from Ubuntu 22.04 LTS to Ubuntu 24.04 LTS version Finally, start the upgrade from Ubuntu 22.04 to 24.04 LTS version. Type: $  sudo do-release-upgrade -d Or you can try upgrading to the latest release using the upgrader from Ubuntu-proposed with version number. For example: $  sudo do-release-upgrade -p '24.04.1 LTS' Are you still getting the following error  after August 29, 2024 ? There is no development version of an LTS available. To upgrade to the latest non-LTS development release set Prompt=normal in /etc/update-manager/release-upgrades. There are multiple ways to upgrade Ubuntu 22.04 LTS before the release of 24.04.1 LTS, scheduled for August 29th, 2024. Here’s one safe method: Edit the  /etc/update-manager/release-upgrades  file and set  Prompt=normal . Run: $  sudo nano /etc/update-manager/release-upgrades Set:   Prompt=normal Save and close the file. Next, run: $  sudo do-release-upgrade Follow all onscreen instructions. This will get you  23.10 release  and reboot the system. Run: $  sudo reboot Then, again edit the  /etc/update-manager/release-upgrades  and set  Prompt=lts . Type: $  sudo nano /etc/update-manager/release-upgrades Set:   Prompt=lts Save and close the file. Finally, type the following command and follow the rest of the guide to upgrade from 23.10 to 24.04 LTS: $  sudo do-release-upgrade -d This note will automatically disappear after August 29th, 2024, as there will be no need for this kind of workaround. As a seasoned sysadmin and developer, I recommend waiting until the release of 24.04.1 LTS (scheduled for August 29th, 2024) before upgrading from Ubuntu 22.04 LTS. This ensures superb stability and minimizes potential compatibility issues with your apps. However, you can use these instructions for testing purposes. This is a great way to check if your applications will work seamlessly with Ubuntu 24.04 LTS. You will get welcome message as follows:   Checking for a new Ubuntu release = Welcome to Ubuntu 24.04 LTS 'Noble Numbat' = The Ubuntu team is proud to announce Ubuntu 24.04 LTS 'Noble Numbat'. To see what's new in this release, visit: https://wiki.ubuntu.com/NobleNumbat/ReleaseNotes Ubuntu is a Linux distribution for your desktop or server, with a fast and easy install, regular releases, a tight selection of excellent applications installed by default, and almost any other software you can imagine available through the network. We hope you enjoy Ubuntu. .... ... To sign up for future Ubuntu announcements, please subscribe to Ubuntu's very low volume announcement list at: http://lists.ubuntu.com/mailman/listinfo/ubuntu-announce Continue [yN] Then it will tell you about ssh port what you already opened: Reading cache Checking package manager Continue running under SSH? This session appears to be running under ssh. It is not recommended to perform a upgrade over ssh currently because in case of failure it is harder to recover. If you continue, an additional ssh daemon will be started at port '1022'. Do you want to continue? Continue [yN] Finally, you need to confirm to start upgrade procedure: Fig.05 : Upgrading Ubuntu from 23.04 or 22.04 to 24.04 (click to enlarge) Dealing with “Remove obsolete packages?” message You will get message as follows: Remove obsolete packages? 27 packages are going to be removed. Continue [yN] Details [d] You need to review those carefully and only remove those packages if you do not need them. Otherwise, choose ‘N’ option. System upgrade is complete The movement has arrived. The system upgrade is complete. All you need to say ‘Y’ to reboot the system and pray that it comes online: Fig.06: Rebooting into Ubuntu 24.04 LTS server (click to enlarge) Step 5 – Verification Use the command lsb_release command or  cat command  to check your Ubuntu Linux version. This command queries the  /etc/os-release  and provides you with the version information: $  cat /etc/os-release Here is what I see: PRETTY_NAME="Ubuntu 24.04.1 LTS" NAME="Ubuntu" VERSION_ID="24.04" VERSION="24.04.1 LTS (Noble Numbat)" VERSION_CODENAME=noble ID=ubuntu ID_LIKE=debian 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" UBUNTU_CODENAME=noble LOGO=ubuntu-logo And: $  lsb_release -a Outputs: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 24.04.1 LTS Release: 24.04 Codename: noble Check the Linux kernel version as follows using the uname command: $  uname -mrs Outputs: Linux 6.8.0-1014-aws x86_64 Please note that the Linux kernel version may very from time to time as new patches are applied to Ubuntu 24.04.xx LTS release. Step 6 – Enabling 3rd party repos/mirros After completing the upgrade to Ubuntu 22.04 LTS (or 23.10) to 24.04 LTS, ensure that you enable 3rd party mirrors and repositories; otherwise, you will not receive updates. Use the following  cd command : $  cd /etc/apt/sources.list.d $  ls -l For example, my app repo was disabled during updates: $  cat my-cool-apps.list Outputs: #deb [arch=amd64] https://dl.www.cyberciti.biz/linux/deb/ stable main To enable it again, I commented out the line by removing the #: deb [arch=amd64] https://dl.www.cyberciti.biz/linux/deb/ stable main Then run the apt command: $  sudo apt update $  sudo apt upgrade Finally, clean up unwanted and unused leftover packages: $  sudo apt autoremove --purge Make sure to remove the iptables/ufw firewall rule that was added earlier to open the alternate SSH port at TCP/1022. For example: $  sudo ufw show added # add the delete rule before the allow keyword $  sudo ufw delete allow 1022/tcp comment 'Open port ssh tcp port 1022 as failsafe option for upgrades' See “ How to delete a UFW firewall rule on Ubuntu / Debian Linux ” for more info. Wrapping up Congratulations! You’ve successfully upgraded your Ubuntu system from 22.04 LTS or 23.10 to the latest 24.04 LTS using the command line. For in-depth details, explore the official Ubuntu 24.04  release notes  and read manual pages using “ man ” or “ help “: $  man do-release-upgrade $  man apt $  man apt-get