How to Upgrade AWS EC2 Ubuntu Version: A Step-by-Step Guide

Upgrading the Ubuntu version on an AWS EC2 instance involves several steps to ensure a smooth transition. Follow this guide to upgrade your AWS EC2 Ubuntu version safely.

Prerequisites

  • An AWS EC2 instance running Ubuntu.
  • SSH access to the instance.
  • A backup of your instance or important data.

Step 1: Connect to Your EC2 Instance

First, connect to your EC2 instance using SSH:

ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns

Or you can use SSH client like Putty.

Step 2: Update Current Packages

Before upgrading, ensure that all current packages are up-to-date:

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y

Step 3: Clean Up Unnecessary Packages

Remove any unnecessary packages to free up space:

sudo apt-get autoremove -y
sudo apt-get clean

Step 4: Check the Current Ubuntu Version

Verify the current Ubuntu version:

lsb_release -a

You may see an output like this:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:        18.04
Codename:       bionic

Step 5: Upgrade to the New Ubuntu Version

Start the upgrade process to the new Ubuntu version. For example, to upgrade from Ubuntu 18.04 to 20.04:

sudo do-release-upgrade

Follow the on-screen instructions to complete the upgrade. You may need to confirm some prompts during the process.

Step 6: Reboot the Instance

After the upgrade is complete, reboot your instance:

sudo reboot

Step 7: Verify the Upgrade

Once the instance has rebooted, reconnect via SSH and verify the new Ubuntu version:

lsb_release -a

After the successfully update you may see the output like below:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

Troubleshooting

If you encounter any issues during the upgrade, check the logs for more details:

sudo less /var/log/dist-upgrade/main.log

Conclusion

Upgrading the Ubuntu version on an AWS EC2 instance is a straightforward process if you follow these steps. Always ensure you have a backup before starting the upgrade to prevent data loss.

By following this guide, you can successfully upgrade your AWS EC2 Ubuntu version.

Sharing Is Caring:
Subscribe
Notify of
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments