I have two separate drivers (let's call them C and D). I had Windows installed on C and a vdhx file (containing a WSL installation) on driver D. I had to reinstall Windows (hence, WSL) on C, but the vdhx file still available on D.

Is there a way to register this existing vdhx file as a WSL 2 distro or would I need to recreate the distro from scratch?

I've tried using wsl.exe --import but it seems to work only for tar files. I also came across wslconfig.exe and saw a switch to unregister a distro, but not to register a new one.

1

Best Answer


The following procedure worked for me:

  1. Open regedit and navigate to Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss. Under this key there is a subkey that looks like a GUID, for each installed distro. Find the one that you want to move to different disk, and export it.
  2. run wsl --unregister DistroName so that you can move the files
  3. move your distro to another location
  4. open the .reg file you exported in step 1, update BasePath value to point to the new location.
  5. import the .reg file