Moving WSL Distributions to Another Drive

Published: (February 18, 2026 at 06:13 PM EST)
7 min read
Source: Dev.to

Source: Dev.to

Moving WSL 2 Distributions to Another Drive

WSL 2 distributions default to your C: drive. That’s fine when you have a single small Ubuntu install, but it quickly becomes a problem when you have several distros each with a 20‑50 GB virtual disk and your system drive is running low on space.

Good news: you can move distributions to any drive.
Less‑good news: there are a few ways to do it, and the right method depends on your WSL version.


Where Are My Distributions Stored?

Before moving anything, locate 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

WSL versionDefault path
Newer WSL%LOCALAPPDATA%\wsl\{GUID}\
Store‑installed distros%LOCALAPPDATA%\Packages\\LocalState\

You can check the size of each VHDX from 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 with their WSL versions:

wsl --list --verbose

The simplest way to move a distribution is the built‑in move command. It relocates the VHDX file and updates the registry in one step.

Step 1 – Stop the distribution

wsl --terminate Ubuntu

Verify it’s stopped:

wsl --list --verbose

You should see Stopped next to the distro name.

Step 2 – Move it

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

WSL will create the destination folder if needed and move the VHDX file. Large VHDX files (e.g., 50 GB) may take several minutes depending on disk speed.

Step 3 – Verify

wsl -d Ubuntu
whoami
ls ~

If the commands run correctly, your distribution is now on D: and WSL knows where to find it. All files, packages, and configuration are preserved.


Method 2 – Export & Import

Use this when --manage --move isn’t available, or when you want to rename the distro. It works on all WSL 2 installations.

Step 1 – Export the distribution

You have three format options:

  • TAR (default, universal)

    wsl --export Ubuntu D:\Backups\ubuntu-backup.tar
  • VHD (faster, preserves disk structure)

    wsl --export Ubuntu D:\Backups\ubuntu-backup.vhdx --format vhd
  • Compressed TAR (smaller file)

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

The VHD format copies the VHDX directly and is considerably faster for large distros.

Step 2 – Unregister the old distribution

wsl --unregister Ubuntu

Warning: This removes the distro from WSL’s registry and deletes the original VHDX. Make sure the export completed successfully (check the file size) before running this command.

Step 3 – Import to the new location

From a TAR export

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

From a VHD export

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

The syntax is: wsl --import .

Step 4 – Fix the default user (only needed for TAR imports)

When importing from a TAR archive, WSL defaults to root. Set your default user by editing /etc/wsl.conf:

wsl -d Ubuntu -u root
cat >> /etc/wsl.conf  **Caution:** This method bypasses the safety checks performed by `--export`/`--import`. Ensure the VHDX is not corrupted and that the destination folder contains only the VHDX (no extra files).

After importing, verify the distro works as described in **Method 1, Step 3**.

---

## Quick Reference Cheat‑Sheet

| Task | Command |
|------|---------|
| List distros & versions | `wsl --list --verbose` |
| Stop a distro | `wsl --terminate ` |
| Move (WSL ≥ 0.58) | `wsl --manage  --move ""` |
| Export (TAR) | `wsl --export  .tar` |
| Export (VHD) | `wsl --export  .vhdx --format vhd` |
| Unregister | `wsl --unregister ` |
| Import (TAR) | `wsl --import  "" .tar` |
| Import (VHD) | `wsl --import  "" .vhdx --vhd` |
| Set default user | Edit `/etc/wsl.conf` with `[user] default=` |
| Delete backup file | `Remove-Item ` |

---

Now you can free up space on your system drive without reinstalling your WSL 2 distributions. Happy hacking!

## Move a VHDX File to a New Location  

You can register the VHDX directly without 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 (all WSL 2 VHDX files are).
It’s the fastest option if you have 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 destination2× (export + import)2× (export + import)
Preserves user settingsYesNo (need to fix)Yes
Rename distroNoYesYes
WSL version requiredRecent WSLAny WSL 2Any WSL 2
ComplexityLowMediumMedium

Recommendation: 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

Prevent the need to move later by specifying the location during installation:

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

The VHDX is created on D: from the start.


The Easy Way: WSL UI

WSL UI provides a point‑and‑click way to move distributions.

Move Distribution dialog

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

No command line, no manual registry edits. It uses WSL’s native move command under the hood, preserving files, settings, default user, and configuration.


Troubleshooting

SymptomCause / Fix
“The operation is not supported” when using --manage --moveYou may be on an older WSL version. Run wsl --update or fall back to export/import.
Import defaults to root userExpected with TAR imports. Edit /etc/wsl.conf (see “Fix default user” below).
“Access is denied” during moveEnsure no WSL processes are using the distro. Run wsl --shutdown then retry.
Distro not showing after importVerify the import path exists and you have write permissions. Run PowerShell as Administrator.
Running out of space during exportExport directly to the destination drive (e.g., D:\Backups\ when moving from C: to D:).

Summary

TaskCommand
List distroswsl --list --verbose
Stop a distrowsl --terminate
Move (simple)wsl --manage --move "D:\WSL\path"
Export (TAR)wsl --export backup.tar
Export (VHD)wsl --export backup.vhdx --format vhd
Unregisterwsl --unregister
Import (TAR)wsl --import "D:\path" backup.tar
Import (VHD)wsl --import "D:\path" backup.vhdx --vhd
Import in‑placewsl --import-in-place "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 a one‑time (or occasional) task, but it can free up a lot of space on a crowded C: drive.

*Originally published at *

0 views
Back to Blog

Related posts

Read more »

Managing WSL Disk Space

Shrinking WSL 2 VHDX Files If you’ve been using WSL 2 for a while, you’ve probably noticed your C: drive slowly losing space 10 GB here, 50 GB there. The culpr...

Renaming WSL Distributions

Renaming WSL Distributions – A Complete Guide You installed Ubuntu from the Microsoft Store and WSL named it Ubuntu‑24.04. You installed another one and got Ub...

Cloning WSL Distributions

Why clone a WSL distribution? You’ve spent hours setting up a WSL distribution—installing packages, configuring your shell, and tuning your development environ...

OpenClaw Is Unsafe By Design

OpenClaw Is Unsafe By Design The Cline Supply‑Chain Attack Feb 17 A popular VS Code extension, Cline, was compromised. The attack chain illustrates several AI‑...