Resource icon

Move a WSL 2 distro to another drive without losing Linux projects

A growing WSL distro can consume a system drive even when its visible Linux folders look small. Microsoft supports exporting and importing distributions, but wsl --unregister permanently deletes the registered instance and should never be the first step. A safer move creates an export, imports under a temporary new name to the destination drive and tests real project files before retiring the old registration. This protects databases, SSH configuration and package state that a fresh distro install would not recreate.

Before you start​

Measure free space on both drives; an export may require substantial extra room. Save work inside Linux, stop development servers and back up irreplaceable files separately. Record wsl --list --verbose output and your Linux username. If a database runs in WSL, make an application-consistent backup as well; a filesystem export alone may not capture an active database cleanly.

Do it step by step​

  1. In PowerShell, run wsl --list --verbose and copy the exact source distro name. Inside Linux, inspect the home directory and project locations you expect to preserve.
  2. Shut down the distro after closing applications with wsl --terminate followed by its exact name. Use wsl --export with that name and a .tar path on a drive with enough free space; wait for the command to complete.
  3. Check that the archive exists, is nonzero and can be copied to another location. Keep it outside the WSL installation folder so deleting or moving that folder cannot destroy the only backup.
  4. Use wsl --import with a distinct temporary distro name, the desired installation folder and the exported tar path. Specify --version 2 if needed; do not overwrite the original registration.
  5. Launch the new name and inspect project files, package commands, permissions and the default Linux user. Imported distributions may start as root until default-user configuration is restored; fix that before daily use.
  6. Run a real project smoke test and a database restore check where applicable. Only after both archive and imported distro work should you choose a new default with wsl --set-default and plan removal of the old one.

Check the result​

The imported distro runs from the intended drive, opens as the expected Linux user and passes a project-specific test. The export remains accessible independent of both registrations.

If something goes wrong​

If import fails, keep the original untouched and verify free space, file permissions, archive path and WSL version. If the imported distro lacks files, inspect the original path and archive rather than unregistering anything. For database corruption, restore from the separate application backup.

Know the limit​

wsl --export defaults to a tar archive; WSL 2 also supports VHD export with different import options. wsl --unregister is destructive and permanent for that registration. A new drive can fail too, so retain an off-device backup of valuable projects. Microsoft WSL commands Microsoft WSL FAQ

Decision checkpoint​

Keep the old registration until the imported copy has passed a full project cycle. Pay special attention to hidden configuration under the Linux home directory, SSH key permissions, scheduled jobs and mounted Windows paths; these can differ on a new drive. For large exports, compare archive size with the original virtual disk and store a second copy away from the PC. If the move was motivated by low C: space, first identify whether caches rather than the whole distro are responsible.
Posted by
Jack
Views
1
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from Jack