Pre-requisites.
To install WSL2, you will need to be running Windows 10 version 1903 or later. To check your Windows 10 version, hold the Windows key and R, and type winver
.
Upgrading from WSL1 to WSL2
To update your current current distros from WSL1 to WSL2, you can run the following command:
wsl --set-version <distro-name> 2
To get a list of your distro names, type:
wsl -l -v
Replace the distro-name with the Name displayed in the name
section
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 again to verify whether the version was successfully upgraded.
Set WSL2 as your default version
Open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:
wsl --set-default-version 2