DEV Community

Eszter Szücs-Mátyás
Eszter Szücs-Mátyás

Posted on

Making a clone of your WSL environment (and using it in parallel)

1. List installed distributions

wsl --list

2. Export Linux Distro to clone

Pick the distribution you want to clone and add use the name in the following command. It will take a snapshot of the distribution to a selected location.

Pro Tipp: You can also use this command to back up your WSL state so you can restore later, or use it on an other Windows instance.

wsl --export <DistributionName> <FileName>

Example:
wsl --export Ubuntu ubuntu.tar.gz

3. Import snapshot as WSL image

In this step, you will install the archive file as a WSL distribution package on the computer, as it would be an app. The InstallationLocation is not optional, you can select any folder freely. The the default location when downloading a distribution image from the app store is _C:\Users<WindowsUserName>\AppData\Local\Packages_, so I tend to select that folder for this purpose as well.
The DistributionName should be different from the original distribution name. In my case I suffixed it with a 2, you might want to choose something more descriptive.
FileName is the exporter archive from the previous step.
wsl --import <InstallationLocation> <DistributionName> <FileName>

Example:
wsl --import C:\Users\dangernoodle\AppData\Local\Packages\Ubuntu-LTS ubuntu-2 rootfs.tar.gz

4. Install and Start distribution

wsl -d <DistributionName>

Example:
wsl -d ubuntu-2

5. Done!

Top comments (0)