wsl --manage <Distro> --move <Location>. The old export, unregister and import routine is no longer necessary.
WSL puts its virtual disks on the system drive, and those disks only ever grow. On a laptop with a modest C: drive, a couple of distributions and Docker will find the limit surprisingly quickly.
The Modern Way: One Command
# stop the distribution first wsl --terminate Ubuntu # move it, disk and all wsl --manage Ubuntu --move D:\WSL\Ubuntu # confirm wsl -l -v
WSL relocates the virtual disk and updates its own registration, so the distribution starts from the new location with everything intact.
The Old Way, Still Documented Everywhere
Most guides online still describe this three-step version, which was the only option before --move existed. It still works, and it is worth knowing because it doubles as the backup routine:
wsl --export Ubuntu D:\Temp\ubuntu.tar wsl --unregister Ubuntu wsl --import Ubuntu D:\WSL\Ubuntu D:\Temp\ubuntu.tar
wsl --unregister deletes the distribution and its filesystem immediately, with no prompt and no recycle bin. Export first, verify the tar file exists and looks a sensible size, then unregister.One more detail: the old routine resets the default user to root, so you will want wsl --manage <Distro> --set-default-user <name> afterwards. The --move command does not have that side effect.
Related
- Back Up and Restore a WSL Distro
- Limit WSL 2 Memory and CPU Usage
- Uninstall a Linux Distro in WSL
- WSL Complete Guide
If SQL Server is part of your day job, my current work lives over at sqldba.blog: production DBA scripts, an error library and the SSMS guide.
Leave a Reply