Upgrading to Ubuntu Server 24.04 LTS: A Practical Guide to a Safe Finish

Ubuntu tutorial - IT technology blog
Ubuntu tutorial - IT technology blog

Real-world Issues: When Should (and Shouldn’t) You Hit the Upgrade Button?

Early in my career, I once took the risk of performing an in-place upgrade on a production server at 10 AM. The results were catastrophic: the server hung during GRUB configuration, services went down, and I spent six hours just recovering data. It was a hard-learned lesson: never mess with OS upgrades without thorough preparation.

Currently, Ubuntu 24.04 LTS (Noble Numbat) has been released with Kernel 6.8, offering better security and significant performance optimizations. Your fleet of 22.04 VPS instances might still be running perfectly fine. However, the need for the latest patches or modern libraries like Python 3.12 and PHP 8.3 will soon urge you to upgrade.

How can you move to 24.04 without staying up all night fixing bugs? How do you ensure your Database, Nginx, or Docker containers keep running smoothly after typing the command? We’ll tackle this challenge like a true Sysadmin.

Root Cause Analysis: Why Do Upgrades Often Fail?

Upgrading Ubuntu isn’t as simple as running a command and waiting. Based on my infrastructure management experience, there are 3 main reasons why systems “die” mid-way:

  1. Repository Conflicts (PPA): This is the number one culprit. If you install too many third-party PPAs (like Ondrej PHP or MariaDB), these packages might be incompatible with the new library structure, leading to serious dependency errors.
  2. Lost SSH Connection: The upgrade process usually takes 20 to 45 minutes. A flaky home network dropping your SSH session while the system is removing old packages is a disaster. At that point, the server is left in a “half-baked” state and often fails to boot.
  3. Running out of Disk Space: This process requires downloading about 1.5GB – 2GB of data and continuous decompression. If the /boot partition has less than 500MB or / has less than 5GB free, the failure rate is almost certain.

Many newcomers switching from CentOS to Ubuntu often confuse apt upgrade with do-release-upgrade. Remember: the former only updates minor packages, while the latter is a full system “overhaul”.

Common Approaches

When you want to move to 24.04, you have 2 main options depending on the importance of the service:

Option 1: Clean Install

This is technically the safest method. You rent a new VPS running 24.04, then migrate your code and database over.

  • Advantages: 100% clean system, completely removing years of accumulated configuration junk.
  • Disadvantages: Requires reconfiguring everything from scratch, making it easy to miss hidden config files in /etc or old cronjobs.

Option 2: In-place Upgrade

Using the official do-release-upgrade tool from Canonical.

  • Advantages: Quick and convenient, preserving all users, data, and folder permissions.
  • Disadvantages: Potential risks if the old system is running too many complex customizations.

Safe 5-Step Upgrade Process (99% Success Rate)

To ensure everything goes smoothly, I recommend following the “slow but steady” process below. This is the standard I apply when managing dozens of servers for clients.

Step 0: Snapshot – The Only Escape Route

Before typing any command, go to your Cloud Provider’s Dashboard (like DigitalOcean, AWS, or Vultr) to create a Snapshot. If something goes wrong, you just need to click “Restore”. Never gamble your data on luck!

Step 1: Clean the Old System

The system must be in its most stable state before upgrading. Run the following commands to update all current packages:

sudo apt update && sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y

After that, reboot the server once to ensure the latest kernel is active and stable.

Step 2: Use Screen – Prevent Unexpected Network Disconnects

Install screen or tmux to keep the session running in the background on the server, even if your computer loses its internet connection.

sudo apt install screen -y
screen -S upgrade_session

If you happen to get disconnected, just log back in and type screen -r upgrade_session to continue monitoring the process.

Step 3: Trigger the Upgrade Command

Type the main control command:

sudo do-release-upgrade

Important Note: If Ubuntu says “No new release found”, it’s because LTS upgrades usually only open officially after the 24.04.1 release. To force the upgrade immediately (with slightly higher risk), use the -d (Development) flag:

sudo do-release-upgrade -d

Step 4: Interaction and Handling Config Files

The system will pause and ask you a few critical questions:

  • Open a backup SSH port: Choose y (usually port 1022). If the main port 22 fails during the version change, you still have a way into the server.
  • Configuration file: When asked to choose between the old or new config file for services like Nginx/MySQL, choose Keep the local version currently installed. Keeping the old configuration files prevents your services from being “frozen” after the reboot.

Step 5: Verification and Cleanup

After the server reboots, check the results:

lsb_release -a
sudo systemctl status nginx mysql docker

Troubleshooting Common Issues

Broken Packages Error: If you encounter a package error message mid-way, stay calm and try resolving it with sudo apt --fix-broken install. Usually, the system can self-repair simple dependencies.

Python Issues: Ubuntu 24.04 uses Python 3.12 by default. If you have old Python scripts running in virtual environments (virtualenv), there’s a high chance you’ll need to delete and recreate them to be compatible with the new interpreter.

Network Interface Name Changes: Sometimes the system renames the interface from eth0 to ens3, causing the server to lose connectivity. If you can’t ping, immediately check the configuration file in /etc/netplan/.

Upgrading the system is a mandatory skill to maintain security and performance for IT infrastructure. Don’t be afraid; just prepare a thorough backup and follow the process. Good luck with successfully bringing your server up to Ubuntu 24.04 LTS!

Share: