How Do You Clone A WSL Distro?

5,402

Solution 1

How would you go about cloning a WSL distro?

You first must export the WSL distribution you wish to clone.

  1. wsl.exe --export OriginalDistributionName FileName
  • OriginalDistributionName is the name of the distribution you wish to export.

  • FileName is the full path to a tar file that will be created.

You must now import the distribution you just cloned with the following command:

  1. wsl.exe --import ClonedDistributionName InstallLocation FileName
  • ClonedDistributionName is the name of the new distribution that will be created.

  • InstallDirectory is path to the folder the distribution will be installed to.

  • FileName is the full path file to the tar file you created in the previous step.

You can start the cloned distribution by running the following command:

  1. wsl --distribution ClonedDistributionName

Source:

Solution 2

You may intall and manage multiple Linux distros under WSL. This is detailed here.

As you say you are seeking to clone a "fresh" distro, the way to do this would be to register the same distro a second time in WSL.

Reinstalling from the store will install a clean copy of the distribution.

EDIT: Do note that the above approach is for replacing your existing distro with a fresh one. To clone an additional copy, the third approach below (cli) is needed. Note too that like many technologies, WSL has changed and will continue to change, and you should always check the documentation for the version you are using.

You may also sideload a custom distro, which may be a way to achieve more control over the naming of your distros and hence register similar distros under the name of your choice.

And you may use the cli to export and import copies of your distros:

enter image description here

Share:
5,402

Related videos on Youtube

Joe
Author by

Joe

Just another user on the StackExchange network.

Updated on September 18, 2022

Comments

  • Joe
    Joe over 1 year

    How would you go about cloning a WSL distro? I have a Debian WSL distribution running under Windows 10 x64 and I would like to clone the distribution without affecting my original one. I have read several documentation over at Microsoft but could not find one explaining this process or if it is even available and can be done. Could anyone please explain how and if it is even possible to clone a fresh WSL distribution of Linux?

  • Giovanni Tirloni
    Giovanni Tirloni about 2 years
    Please note that if the distribution you're cloning is currently running, it'll be stopped without warning.