WSL2 container is located on the
C:\ drive by default.
This can be inconvenient, as it can grow to a substantial size.
The size of the container becomes a particular concern considering that to reap WSL2’s performance benefits, one should store the data directly in the container.
While there are guides on how to import a new distribution via PowerShell, there’s little information on how to simply move an existing container that is connected to an existing Linux WSL2 installation (e.g.
- Open PowerShell:
$ wsl --list --verbose
Note the name of the distribution of interest: ```console NAME STATE VERSION
- Ubuntu Running 2 ```
- Shut down all WSL containers:
$ wsl --shutdown
- Open the Windows Registry Editor and navigate to:
There, you will see the same number of keys as you have WSL distributions with random names, e.g.
Inspect the contents of those keys, and specifically look for the value
Naturally, you’re looking for the key with the
DistributionNamevalue equal to the name of your distribution of interest.
- Once located, Open the
BasePathvalue. It’ll look something like that:
Follow the path, where you’ll find a file aptly named
Copy this file to your new destination, e.g.
Replace the path in the
BasePathvalue with the new one (e.g.
- All done!