Move WSL2 vhdx
The problem
- Your primary drive has low space
- WSL2 is consuming a lot of space
Causes
- The vhdx is a no-shrinking file
Solution
- Move the vhdx to another drive
How
Execute this code i got from here
wsl --shutdown
wsl -l -v
wsl --export <DistroName> <PathToTarArchive>
wsl --unregister <DistroName>
wsl --import <DistroName> <PathToDistroNewDirectory> <PathToTarArchive>
wsl -l -v
Example
Note you have to put the .tar, otherwise the access is denied at the beginning happens.
Additionally clean docker vhdx space
- This space doesn’t show in docker except in the troubleshoot page.
- Press Clean/Purge data