1

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 Windows 10), how can I migrate 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         2

Which is WSL 1. I would like to go to WSL 2.

Soleil
  • 428

3 Answers3

2

That'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 https://aka.ms/wsl2
The Legacy distribution does not support WSL 2.

For migration of files to another distribution, there are two possible ways.

  1. First check if wsl.exe --help shows a --export options. 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 with wsl.exe --unregister Legacy command. And reinstall the distribution with wsl.exe --import command.

  2. Or run the Legacy distribution and tarball the whole distribution, see this answer. Then uninstall Legacy distribution and reinstall it from that tarball.

From github and thanks to Ramhound.

Henke
  • 1,261
Soleil
  • 428
0

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.

user219095
  • 65,551
0

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 /norestart

Reboot 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 from WSL2 Linux kernel update package for x64 machines.

Before starting I suggest backing up the Linux distribution. See the article Export and Import WSL Linux Distro in Windows 10 and also to create a Windows System Restore save.

harrymc
  • 498,455