I have WSL (Linux subsystem on Windows 10) installed with ubuntu 21.04 (not from the store, it's the first version that appeared on W10), how can I to a migration to version 2 (with an actual kernel) while keeping all my files (system and user), if possible without reinstalling everything ?
EDIT wsl -l -v gives:
NAME STATE VERSION
* Legacy Running 1 Ubuntu-20.04 Stopped 2Which is WSL 1. I would like to go to WSL 2.
83 Answers
That’s super trivial, though reading the docs should come first.
$ wsl --help
… --set-version <Distro> <Version> Changes the version of the specified distribution.So just do wsl --set-version MyDistro 2, wait a little, and that’s it.
It might be required to fire up a PowerShell that is Run as Administrator and enter:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestartReboot and enter:
wsl --set-default-version 2
wsl --set-version Ubuntu 2 (use the name of your distribution)If you have any problems, please let us know.
You could also do the upgrade manually by downloading and executing the WSL kernel latest package fromWSL2 Linux kernel update package for x64 machines.
Before starting I suggest backing up the Linux distribution. See the articleExport and Import WSL Linux Distro in Windows 10and also to create a Windows System Restore save.
4That's not possible:
wsl --set-version Legacy 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit
The Legacy distribution does not support WSL 2.For migration of files to another distribution, there are two possible ways.
First check if
wsl.exe --helpshows a--exportoptions. If yes then export the installed distribution to a tar file. For example the command will be:wsl.exe --export Legacy myfile.tar. Then uninstall the Legacy distribution withwsl.exe --unregister Legacycommand. And reinstall the distribution withwsl.exe --importcommand.Or run the Legacy distribution and tarball the whole distribution, see this answer. Then uninstall Legacy distribution and reinstall it from that tarball.