·6 min read·#wsl#windows#disk-management#migration

Moving WSL Distributions to Another Drive

Moving WSL Distributions to Another Drive architecture diagram

WSL2 distributions default to your C: drive. That's fine when you have one small Ubuntu install. It's less fine when you have five distros, each with a 20-50GB virtual disk, and your system drive is running out of space.

The good news: you can move distributions to any drive. The less good news: there are a couple of ways to do it, and the right approach depends on your WSL version.

Where Are My Distributions Stored?

Before moving anything, let's find where your distros currently live. WSL stores each distribution's virtual hard disk (VHDX) in a base path registered in the Windows Registry:

HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss\{GUID}\BasePath

Common default locations:

  • Newer WSL: %LOCALAPPDATA%\wsl\{GUID}\
  • Store-installed distros: %LOCALAPPDATA%\Packages\<distro-package>\LocalState\

You can check your distro sizes from PowerShell:

powershell
Get-ChildItem -Path "$env:LOCALAPPDATA\wsl" -Recurse -Filter "ext4.vhdx" | Select-Object FullName, @{N='SizeGB';E={[math]::Round($_.Length/1GB, 2)}}

Or list all your distributions and their WSL versions:

powershell
wsl --list --verbose

The simplest way to move a distribution is WSL's built-in move command. This relocates the VHDX file and updates the registry in one step.

Step 1: Stop the Distribution

The distro must be stopped before moving:

powershell
wsl --terminate Ubuntu

Verify it's stopped:

powershell
wsl --list --verbose

Look for "Stopped" next to your distro name.

Step 2: Move It

powershell
wsl --manage Ubuntu --move "D:\WSL\Ubuntu"

WSL will create the destination directory if needed and move the VHDX file. This can take a while for large distros — a 50GB VHDX will take a few minutes depending on your disk speed.

Step 3: Verify

Start the distro and confirm everything works:

powershell
wsl -d Ubuntu
bash
whoami ls ~

That's it. Your distribution is now on D: and WSL knows where to find it. All your files, installed packages, and configuration are preserved.

Method 2: Export and Import

If --manage --move isn't available on your WSL version, or if you want to rename the distro at the same time, the export/import approach works on all WSL2 installations.

moving-wsl-distributions-to-another-drive/export-import-workflow diagram
Click to expand
358 × 721px

Step 1: Export the Distribution

You have two format options:

TAR format (default, universal):

powershell
wsl --export Ubuntu D:\Backups\ubuntu-backup.tar

VHD format (faster, preserves disk structure):

powershell
wsl --export Ubuntu D:\Backups\ubuntu-backup.vhdx --format vhd

The VHD format is significantly faster because it copies the VHDX file directly instead of creating a tar archive from the filesystem. For large distros, this can save considerable time.

Compressed TAR (smaller file):

powershell
wsl --export Ubuntu D:\Backups\ubuntu-backup.tar.gz --format tar.gz

Step 2: Unregister the Old Distribution

This removes the distribution from WSL's registry and deletes the original VHDX:

powershell
wsl --unregister Ubuntu

Warning: This deletes the original distribution data. Make sure your export completed successfully before running this. Check the file size of your export — it should be reasonable (not 0 bytes).

Step 3: Import to the New Location

From a TAR export:

powershell
wsl --import Ubuntu "D:\WSL\Ubuntu" D:\Backups\ubuntu-backup.tar

From a VHD export:

powershell
wsl --import Ubuntu "D:\WSL\Ubuntu" D:\Backups\ubuntu-backup.vhdx --vhd

The arguments are: wsl --import <name> <install-location> <file-path>.

Step 4: Fix the Default User

When you import from a TAR archive, WSL defaults to logging in as root. You need to restore your default user. Edit /etc/wsl.conf inside the distro:

powershell
wsl -d Ubuntu -u root
bash
cat >> /etc/wsl.conf << 'EOF' [user] default=yourusername EOF exit

Then restart the distro for the change to take effect:

powershell
wsl --terminate Ubuntu wsl -d Ubuntu whoami

This should now show your username instead of root.

Note: If you exported as VHD format, the /etc/wsl.conf file is preserved as-is inside the VHDX, so your default user setting should already be correct.

Step 5: Clean Up

Once everything is working, delete the backup file:

powershell
Remove-Item D:\Backups\ubuntu-backup.tar

Method 3: Import In-Place (Advanced)

If you've already manually copied a VHDX file to a new location, you can register it directly without WSL copying it again:

powershell
wsl --import-in-place Ubuntu "D:\WSL\Ubuntu\ext4.vhdx"

This tells WSL to use the VHDX at its current location. The file must be ext4-formatted (which all WSL2 VHDX files are). This is the fastest option if you've already moved the file yourself.

Choosing the Right Method

Factor--manage --moveExport/Import (TAR)Export/Import (VHD)
SpeedFast (direct move)Slow (tar + extract)Medium (file copy)
Disk space neededJust the destination2x (export + import)2x (export + import)
Preserves user settingsYesNo (need to fix)Yes
Rename distroNoYesYes
WSL version requiredRecent WSLAny WSL2Any WSL2
ComplexityLowMediumMedium

For most people, --manage --move is the right choice. Use export/import when you need to rename the distro or are on an older WSL version.

Installing New Distros on a Different Drive

Prevention is better than cure. When installing new distributions, you can specify the location upfront:

powershell
wsl --install Ubuntu --location "D:\WSL\Ubuntu"

This puts the VHDX on D: from the start, avoiding the need to move it later.

The Easy Way: WSL UI

WSL UI makes moving distributions a point-and-click operation. The Move Distribution dialog:

  1. Shows the current location and disk size
  2. Lets you browse to a new location
  3. Handles stopping the distro, moving the files, and updating the registry
  4. Shows progress for large moves

No command line, no worrying about which method to use, no manual registry updates. It uses WSL's native move command under the hood, so everything is preserved — your files, settings, default user, and configuration.

Troubleshooting

"The operation is not supported" when using --manage --move: You may be on an older WSL version. Update with wsl --update or use the export/import method instead.

Import defaults to root user: This is expected with TAR imports. Edit /etc/wsl.conf as described in Step 4 of Method 2.

"Access is denied" during move: Make sure no WSL processes are using the distro. Run wsl --shutdown to stop everything, then try again.

Distro not showing after import: Check that the import path exists and you have write permissions. Try running PowerShell as Administrator.

Running out of space during export: Export to the destination drive directly. For example, if moving from C: to D:, export to D:\Backups\ instead of a location on C:.

Summary

TaskCommand
List distroswsl --list --verbose
Stop a distrowsl --terminate <distro>
Move (simple)wsl --manage <distro> --move "D:\WSL\path"
Export (TAR)wsl --export <distro> backup.tar
Export (VHD)wsl --export <distro> backup.vhdx --format vhd
Unregisterwsl --unregister <distro>
Import (TAR)wsl --import <name> "D:\path" backup.tar
Import (VHD)wsl --import <name> "D:\path" backup.vhdx --vhd
Import in-placewsl --import-in-place <name> "D:\path\ext4.vhdx"
Install on D:wsl --install Ubuntu --location "D:\WSL\Ubuntu"
Fix default userEdit /etc/wsl.conf[user]default=username

Moving a distro is one of those tasks you only do once or twice, but it makes a real difference when your C: drive is filling up.

← Back to all posts