In PowerShell terminal, go to desired location. Eg, G:
wsl -l
to see distros, eg:
Ubuntu-20.04 (Default)
docker-desktop-data
docker-desktop
then:
wsl --export Ubuntu-20.04 ubuntu.tar
wsl --export docker-desktop-data docker-desktop-data.tar
wsl --export docker-desktop docker-desktop
That will create the backups files. When you're happy that the files are there and have some size, it's time to get rid of them from the original location (typically C
drive):
wsl --unregister Ubuntu-20.04
wsl --unregister docker-desktop-data
wsl --unregister docker-desktop
When done, it's time to import them to the new location. For example, G:/wsl
and G:/docker
:
wsl --import Ubuntu-20.04 G:\wsl\Ubuntu-20.04\ .\ubuntu.tar --version 2
wsl --import docker-desktop-data G:\docker\docker-desktop-data\ .\docker-desktop-data.tar --version 2
wsl --import docker-desktop G:\docker\docker-desktop\ .\docker-desktop.tar --version 2
Once installed and happy of the new locations, the .tar
files can be removed.
You may need to reset the default user for the ubuntu distribution (due to a current export/import bug). That can be done by using the distro's config command in PowerShell and substituting <username>
for the actual username you want to make default.
ubuntu2004 config --default-user <username>