This is a post on how to upgrade to WSL 2. The demo below will explain the process of upgrading an installed Windows Subsystem for Linux distribution from running WSL version 1 to WSL version 2.
WSL has two versions, the latest (WSL 2), and the original version (WSL 1). You can have many different Linux Distributions installed on your machine, and you can easily change the WSL version of one of them.
My other post, How to Check Installed WSL Versions, will help explain the key and why you might want to perform a WSL upgrade for particular development needs. If you are not going to be using advanced WSL features, then upgrading to WSL 2 is likely a good option for you.
This is a guide to help upgrade WSL version 2 to WSL version 1. If you are looking to go the other way and downgrade from WSL v2 to WSL v1, see my other post -> How to Downgrade from WSL Version 2 to WSL Version 1
How to Upgrade from WSL V1 to V2
To upgrade a WSL distribution from WSL version 1 to version 2, run
wsl <distro-name> --set-version 2. You can get the Linux distribution by running
wsl -l- v.
The WSL commands required for this are shared in the example below:
# check wsl distro versions wsl -l -v # change wsl distro using name above to desired version wsl --set-version Debian 2
The screenshot above shows us listing the installed WSL distros and setting the WSL version for the Debian instance from WSL 1 to WSL2.
The WSL Linux distro will be updated immediately to WSL v2.
To downgrade back to version 1, it’s as simple as changing the number from a 2 to a 1 in the command. As mentioned above in this guide, the following posts may also help provide more info on this:
– How to Check Installed WSL Versions
– How to Downgrade from WSL Version 2 to WSL Version 1