Upgrade Ubuntu 22.04 to 24.04 on WSL

September 19, 2024

Introduction

Windows Subsystem for Linux (WSL) allows users to run Ubuntu and other Linux distributions on Windows machines without creating separate virtual machines (VMs) or dual booting. While a dedicated WSL image is published for each new version of Ubuntu, upgrading an installed instance to a newer operating system (OS) version is possible.

This article will show how to upgrade the Ubuntu 22.04 long-term support (LTS) release to 24.04 LTS on WSL.

Upgrade Ubuntu 22.04 to 24.04 on WSL.

Prerequisites

  • Windows Subsystem for Linux (WSL) installed on Windows.
  • Ubuntu 22.04 installed on WSL.
  • Administrative access on the Windows host and the Ubuntu WSL instance.

Upgrade Ubuntu on WSL

The Ubuntu upgrade process on WSL involves:

  • Backing up the Ubuntu instance.
  • Enabling upgrades inside Ubuntu.
  • Performing the in-place upgrade.

Follow the steps below to upgrade an Ubuntu 22.04 LTS instance to Ubuntu 24.04 LTS.

Step 1: Locate Ubuntu 22.04 Instance

Open a PowerShell or Command Prompt window and use the following command to list the available WSL instances:

wsl -l

Find and note the name of the instance in the command output.

Viewing available WSL OS instances.

Step 2: Create Backup

Since performing an in-place OS upgrade may lead to the WSL instance becoming corrupted, creating a backup is recommended. Back up the Ubuntu 22.04 instance by entering the command below:

wsl --export [wsl_instance_name] [path_to_backup]/[filename].tar

For example, to back up the instance named Ubuntu-22.04 to the Ubuntu_22_04.tar file located at c:\backups, type the following:

wsl --export Ubuntu-22.04 c:\backups\Ubuntu_22_04.tar

The output confirms the operation was successful.

Exporting a backup of an Ubuntu 22.04 WSL instance.

Step 3: Update and Upgrade Packages on Ubuntu 22.04

Before starting the upgrade process, ensure the Ubuntu system is up-to-date:

1. Start the instance by typing the following wsl command:

wsl -d [wsl_instance_name]
Switching to an Ubuntu 22.04 instance.

2. Use APT to update repository lists and perform the necessary upgrades:

sudo apt update && sudo apt upgrade -y

Step 4: Edit release-upgrades File

Ubuntu WSL instances do not allow upgrading to a new release by default. Apply the following steps to change this behavior:

1. Open the release-upgrades file in a text editor like Nano:

sudo nano /etc/update-manager/release-upgrades

2. Find the Prompt=never line and change it to Prompt=lts. Setting the Prompt parameter to lts tells Ubuntu to suggest upgrades if a newer LTS release is available.

Editing the release-upgrades file on Ubuntu 22.04.

3. Save the file and exit.

Step 5: Perform Upgrade

Proceed with the steps below to perform a release upgrade procedure on Ubuntu 22.04:

1. Use the following command to search for release upgrades:

sudo do-release-upgrade

The system displays an Ubuntu 24.04 LTS prompt.

Starting the upgrade procedure on Ubuntu 22.04.

2. Type y and press Enter to continue.

Continuing the upgrade process.

3. Enter y at the following prompt to start the upgrade.

Confirming the upgrade process.

4. When prompted, select Yes in the Configuring libc6 dialog to avoid interruptions related to service restarts.

Configuring the libc6 prompt.

5. After downloading and installing new packages, the system offers to remove obsolete packages. Type y and press Enter to proceed.

Confirming the action of deleting obsolete packages.

Wait for the upgrade process to finish.

Step 6: Restart Instance

The Ubuntu instance needs to be restarted before it runs the upgraded version of Ubuntu. Follow the steps below to complete the restart procedure and test the upgraded instance:

1. Exit the WSL instance:

exit

2. Terminate all instance processes:

wsl --terminate [wsl_instance_name]
Terminating an Ubuntu 22.04 instance.

3. Start the instance again:

wsl -d [wsl_instance_name]

4. Once in Ubuntu, type the command below to see the release version information:

lsb_release -a

The output shows that the system running on the instance is now Ubuntu 24.04 LTS.

Checking Ubuntu version to confirm the success of the upgrade.

Conclusion

This article presented the simple procedure for performing an in-place upgrade of Ubuntu 22.04 to Ubuntu 24.04 in WSL. Upgrading a WSL instance lets you move to a newer Ubuntu release while keeping all the files and settings from the previous one.

Next, improve package management on your Windows system by learning How to Install Winget.

Was this article helpful?
YesNo
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
How to Run Podman on Windows
May 18, 2022

Although Podman runs Linux containers, it is available on Windows machines through WSL.
Read more
How to Install Ansible on Windows
May 30, 2024

Ansible requires a Linux-based system to run, which can be an issue if you want to use it in Windows.
Read more
How to Access Ubuntu via Remote Desktop from Windows
October 12, 2023

Find out how to seamlessly connect to an Ubuntu system from Windows using RDP.
Read more
Install Ubuntu on Windows with Hyper-V
June 24, 2021

This tutorial features a step-by-step process of installing Ubuntu on a VM using Hyper-V on Windows.
Read more