Where Are Wsl Files Stored In Windows __full__ May 2026
username = os.environ.get('USERNAME') base_path = Path(f'C:/Users/username/AppData/Local/Packages')
# Get WSL distribution list wsl -l -v (Get-AppxPackage -Name " Ubuntu ").InstallLocation Navigate to WSL Linux filesystem from Windows \wsl.localhost[DistributionName]\ Example: \wsl.localhost\Ubuntu\home\username
Write-Host "WSL distribution '$DistributionName' not found or is WSL1" -ForegroundColor Red return $null Get-WSLStorageLocation "Ubuntu" Bash Script to Find WSL Files #!/bin/bash Find WSL distribution storage from Linux side find_wsl_storage() head -1) if [ -n "$package_dir" ]; then local vhdx_path="$package_dir/LocalState/ext4.vhdx" if [ -f "$vhdx_path" ]; then echo "Found VHDX: $vhdx_path" ls -lh "$vhdx_path" else echo "WSL1 distribution detected (no VHDX file)" echo "Rootfs location: $package_dir/LocalState/rootfs/" fi else echo "Distribution not found" fi else echo "Cannot access Windows path from Linux" echo "Try running from Windows PowerShell instead" fi where are wsl files stored in windows
Default WSL 2 Storage Location C:\Users\[YourUsername]\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\ext4.vhdx Distribution-Specific Paths | Distribution | Store Package Name | |--------------|-------------------| | Ubuntu | CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc | | Ubuntu 22.04 | CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc | | Ubuntu 20.04 | CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc | | Debian | TheDebianProject.DebianGNULinux_76v4gfsz19hv4 | | Kali Linux | KaliLinux.54290C8133FEE_ey8k8hqnwqnmg | | openSUSE | 46932SUSE.openSUSELeap42.2_022rs5j4ny28 | Find Your WSL Files via Command Line PowerShell / CMD:
if ($packageDir) $vhdxPath = Join-Path $packageDir.FullName "LocalState\ext4.vhdx" if (Test-Path $vhdxPath) Write-Host "WSL2 VHDX Location: $vhdxPath" -ForegroundColor Green # Get file size $file = Get-Item $vhdxPath $sizeGB = [math]::Round($file.Length / 1GB, 2) Write-Host "Size: $sizeGB GB" return $vhdxPath username = os
find_wsl_storage "Ubuntu" # Export distribution wsl --export Ubuntu D:\backups\ubuntu.tar Import to new location wsl --import Ubuntu D:\WSL\Ubuntu D:\backups\ubuntu.tar --version 2 Remove old distribution wsl --unregister Ubuntu Quick Reference Card | Action | Command/Path | |--------|--------------| | Access Linux files from Windows | \\wsl$\Ubuntu\ | | Find VHDX location (WSL2) | %LOCALAPPDATA%\Packages\*\LocalState\ext4.vhdx | | Find rootfs location (WSL1) | %LOCALAPPDATA%\Packages\*\LocalState\rootfs\ | | List distributions | wsl -l -v | | Open WSL home in Explorer | explorer.exe \\wsl$\Ubuntu\home |
Always use \\wsl$\ path or WSL commands to interact with Linux files. Direct Windows file manipulation can corrupt your WSL installation! = 3: distros.append( 'name': parts[0]
distros = [] for line in lines: if line.strip(): parts = line.split() if len(parts) >= 3: distros.append( 'name': parts[0], 'state': parts[1], 'version': parts[2] ) return distros def get_vhdx_path(distribution): """Get VHDX file path for a WSL2 distribution""" package_patterns = 'ubuntu': 'CanonicalGroupLimited.Ubuntu', 'debian': 'TheDebianProject.DebianGNULinux', 'kali': 'KaliLinux',