Linux – How Do You Clone A WSL Distro

linuxlinux-distributionswindows 10windows-subsystem-for-linuxwsl2

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?

Best Answer

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:

Related Question