How to Find WSL Distro Paths and Import VHDX Files| Sabbirz | Blog

How to Find WSL Distro Paths and Import VHDX Files

WSL Find the Distro Location

Find WSL Distro Location & Import a VHDX

VHDX wsl tutorial developer tools PowerShell wsl import WSL troubleshooting wsl configuration wsl basic wsl Linux on Windows Windows Subsystem for Linux WSL2 WSL Location find wsl path wsl backup Import WSL WSL export import wsl distro WSL commands WSL Scripts

Need to manage your Windows Subsystem for Linux (WSL) environments for backups or to save disk space? This guide gets straight to the point, giving you the exact commands to quickly find where your WSL distros are stored and how to import one from a .vhdx file.

Find Your WSL Distribution's Location 📂

To see where all your WSL distributions are stored, open a PowerShell terminal and run this one-liner.

The Command

Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object { Get-ItemProperty $_.PSPath } | Select-Object DistributionName, BasePath

This command queries the Windows Registry and lists all registered distributions and their BasePath (the folder containing the virtual disk).

Example Output

DistributionName BasePath
---------------- --------
Ubuntu-22.04     C:\Users\USER\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc\LocalState
docker-desktop   \\?\F:\Users\USER\AppData\Local\Docker\wsl\DockerDesktopWSL\main
u24superset      C:\Users\USER\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu24.04LTS_79rhkp1fndgsc\LocalState
U22              \\?\E:\wslDistro\Ubuntu-22.04
u24              \\?\E:\wslDistro\Ubuntu-24.04

Import a WSL Distro from a VHDX File 🚀

The wsl --import command lets you register a .vhdx file as a new WSL distribution. This is perfect for restoring backups or moving environments to a new drive.

The Command Syntax

The command structure is: wsl --import --vhd <NewDistroName> <InstallLocation> <PathToVHDXFile> --version 2

  • <NewDistroName>: The name for your new distro (e.g., ubuntu-clone).
  • <InstallLocation>: The folder where the new distro will be stored.
  • <PathToVHDXFile>: The full path to your .vhdx file.

Practical Example

To import an ext4.vhdx file as a new distro named u24superset and place it in D:\wslDistro, run this:

wsl --import --vhd u24superset "D:\wslDistro" "D:\wslDistro\superset\ext4.vhdx" --version 2

A success message confirms the import is complete. You can now launch your new distro with wsl -d u24superset.

Bonus Tip: Exporting a Distro 📦

To create a .vhdx file from an existing distro, use the wsl --export command. This is the first step for any backup or migration.

wsl --export <DistroToExport> <PathForNewVHDXFile>

Example: wsl --export Ubuntu-22.04 "D:\backups\ubuntu-backup.vhdx"

With these commands, you can efficiently manage, back up, and move your WSL environments.