Upgrading from WSL1 to WSL2 (2024)

Aditya Kanekar

Posted on • Updated on

Upgrading from WSL1 to WSL2 (2) Upgrading from WSL1 to WSL2 (3) Upgrading from WSL1 to WSL2 (4) Upgrading from WSL1 to WSL2 (5) Upgrading from WSL1 to WSL2 (6)

#windows #wsl2 #linux #wsl

In my last post I talked about how to get started with developing applications on Linux on Windows 10 using WSL 2 and VS Code. Some of you might have installed the previous version of WSL1 on your Windows 10 machines. This article guides on how to upgrade from WSL to WSL2.

You need at least 1903 version of Windows 10. You can check the minimum requirement for upgrading from WSL1 here To check windows version, click Windows + R Key and type,

winver

You will be able to see the build version of your windows e.g. 1903.

Download the installer for the WSL2 kernel from,
https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel

Run the installer to install WSL2 Kernel for Linux. Once the installation is successful. Open PowerShell or command prompt and run,

wsl --list 

This will list all the distros and the version of WSL in the version column. The list will look somewhat similar to this,

Upgrading from WSL1 to WSL2 (7)

Since you were running WSL1 previously on your machine the distro is still using WSL1. No magic tricks here, none of your distros will be migrated to WSL2 by default.

Upgrading from WSL1 to WSL2

To upgrade your current distro(s) from WSL1 to WSL2. Run following command in PowerShell or command prompt,

wsl --set-version <distro-name> 2

Replace the distro-name with the Name displayed in the last section. So in our case the command will look like,

wsl --set-version Ubuntu-20.04 2

This will take some time to upgrade, in my experience all your data will be retained as it was previously. Once the upgrade is complete you can run the list distros command to verify whether the version was successfully upgraded.

wsl -l -v

You should be able to see output similar to,

Upgrading from WSL1 to WSL2 (8)

Now you can launch Ubuntu-20.04 from Start menu or from the command prompt run,

wsl -d Ubuntu-18.04

This will take you to the Ubuntu-18.04 shell. The * denotes the default distribution. What does that mean? To check run following command,

wsl

This will take you to Ubuntu-20.04 shell without mentioning the distro. If you want to change the default distro run,

wsl -s Ubuntu-18.04wsl -l -v

You will notice the default distribution changed to Ubuntu-18.04.

NAME STATE VERSION

  • Ubuntu-18.04 Stopped 2Ubuntu-20.04 Stopped 2

Now if you run,

wsl

Ubuntu-18.04 shell will launch. To verify if the right version is launched. Run following command,

lsb_release -a

You should get output similar to,

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

Now open another PowerShell or command prompt window and run,

wsl -l -v

You will notice Ubuntu-18.04 is in Running state. IF you close the wsl window or run exit the state will change to Stopped.

Upgrading from WSL1 to WSL2 (9)

Hopefully this will get you started on WSL2. In my next articles we will use WSL for running tools supported on Linux environment.

Till then, happy coding!

Top comments (9)

jereje

jereje

  • Joined

Feb 3 '22

  • Copy link

Thanks! Worked like a charm

Abod

Abod

Freelancer, Software Engineer and the founder of Whilelab

  • Location

    Remote

  • Work

    Software Engineer

  • Joined

Mar 22 '21

  • Copy link

Thanks for the amazing article, I've put upgrading for months because I thought it was going to delete all the distro files, but after reading the article and your experience, I went for it, and all is good.

Mayukh Chatterjee

Mayukh Chatterjee

Seeker of Reality.Founder KnittingThoughts.

  • Email

    me.mayukhchatterjee@gmail.com

  • Location

    Kolkata

  • Education

    Student at Heritage Institute Of Technology.

  • Work

    Computer Engineer

  • Joined

Jul 26 '21

  • Copy link

what if i upgrade wsl1 to wsl2, will i lost the other downloded tools like GCC, valgrind,gdb?

Aditya Kanekar

Aditya Kanekar

Cloud Architect & Tech Enthusiast

  • Location

    Mumbai

  • Education

    B.E. Computer

  • Work

    Sr. Solution Architect at CitiusTech

  • Joined

Jul 31 '21

  • Copy link

None of my files were lost in the process, so I assume it will retain the tools. However I am not so sure on this one, but you can always reinstall the tools.

Ahmad

Ahmad

Like to see colorful code

  • Location

    Indonesia

  • Education

    Universitas Trunojoyo Madura

  • Work

    Student at None

  • Joined

May 6 '21

  • Copy link

Thanks a lot brother, you've help me..
Firstly, I little confused read official docs about this topic. until I found this

Verlaine_Devnet

Verlaine_Devnet

I am a devoted learner and Aspiring Cisco developer.I love learning something new daily, For the last 10 years, I was between IT and the startup weekend community as an active contributor.

  • Education

    No university Degree

  • Work

    Freelance dev

  • Joined

Nov 23 '22

  • Copy link

Excellent Article !

jpdev

jpdev

  • Joined

Mar 8 '21

  • Copy link

thanks... it took around 10-15 minutes here

Abod

Abod

Freelancer, Software Engineer and the founder of Whilelab

  • Location

    Remote

  • Work

    Software Engineer

  • Joined

Mar 22 '21

  • Copy link

NOTE: if you have configured docker for WSL 1, and now you're upgrading make sure to remove the DOCKER_HOST variable from your Linux distro config

Pratap Parui

Pratap Parui

//Life Motto if (sad()===True){sad().stop();beAwesome();}

  • Location

    Mumbai,India

  • Education

    Computer Science Graduate

  • Pronouns

    He/Him

  • Work

    Frontend Developer,Designer,Cloud Enthusiast and Blogger

  • Joined

Mar 1 '23

  • Copy link

Thanks Aditya it's help a lot

For further actions, you may consider blocking this person and/or reporting abuse

Upgrading from WSL1 to WSL2 (2024)
Top Articles
Latest Posts
Article information

Author: Mrs. Angelic Larkin

Last Updated:

Views: 6393

Rating: 4.7 / 5 (47 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Mrs. Angelic Larkin

Birthday: 1992-06-28

Address: Apt. 413 8275 Mueller Overpass, South Magnolia, IA 99527-6023

Phone: +6824704719725

Job: District Real-Estate Facilitator

Hobby: Letterboxing, Vacation, Poi, Homebrewing, Mountain biking, Slacklining, Cabaret

Introduction: My name is Mrs. Angelic Larkin, I am a cute, charming, funny, determined, inexpensive, joyous, cheerful person who loves writing and wants to share my knowledge and understanding with you.