C:\Users\JohnSmith\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc\LocalState\ext4.vhdx Method 1: Via PowerShell (Easiest) Open PowerShell as Administrator and run:
Get-ChildItem "C:\Users\$env:USERNAME\AppData\Local\Packages" -Filter "*ext4.vhdx" -Recurse -ErrorAction SilentlyContinue Inside your WSL distro, run: wsl distro location
# In Windows PowerShell (Admin) Optimize-VHD -Path D:\wsl\Ubuntu\ext4.vhdx -Mode Full Now you can keep your C: drive breathing room while your Linux environment lives happily on a larger SSD or HDD. Have questions or another WSL tip? Drop a comment below! wsl distro location
If you’ve installed WSL (Windows Subsystem for Linux) and started filling up your $HOME directory with projects, you might suddenly realize your C: drive is shrinking. By default, WSL stores its virtual hard disks ( .vhdx files) on your Windows drive. wsl distro location
# Find the block device df -h / wsl.exe --list --verbose