Skip to content

Instantly share code, notes, and snippets.

@xbalaji
Created May 29, 2025 03:40
Show Gist options
  • Save xbalaji/01089e1f7ccfd0d03a47f246006d81e5 to your computer and use it in GitHub Desktop.
Save xbalaji/01089e1f7ccfd0d03a47f246006d81e5 to your computer and use it in GitHub Desktop.
windows-cleanup.md

1. How to use WSL in a different partition of my Windows machine?

Answer:

You can install or move WSL distros to a different partition like this:

Option 1: Install a New WSL Distro to a Different Drive

  1. Download .appx file (e.g., Ubuntu).

  2. Extract it to D:\WSL\Ubuntu using Expand-Archive.

  3. Register it via:

    .\ubuntu.exe install --root

Or:

wsl --import UbuntuCustom D:\WSL\Ubuntu .\install.tar.gz

Option 2: Move an Existing Distro

  1. Export it:

    wsl --export Ubuntu D:\WSL\ubuntu_backup.tar
  2. Unregister:

    wsl --unregister Ubuntu
  3. Import:

    wsl --import Ubuntu D:\WSL\Ubuntu D:\WSL\ubuntu_backup.tar

2: What is the file AppData\Local\Docker\wsl\data\ext4.vhdx?

Answer:

It’s a virtual hard disk (VHDX) used by Docker Desktop for storing:

  • Docker images
  • Containers
  • Volumes

Located at:

%USERPROFILE%\AppData\Local\Docker\wsl\data\ext4.vhdx

If Docker Desktop was removed, this file may still remain. It can be deleted if you're sure Docker is not in use.


3: I don’t have Docker Desktop installed

Answer:

If you see ext4.vhdx but don’t have Docker Desktop, it likely remains from a previous installation.

You can:

  1. Run:

    wsl --list --verbose

    If you see docker-desktop*, unregister them:

    wsl --unregister docker-desktop
    wsl --unregister docker-desktop-data
  2. Then delete:

    C:\Users\<You>\AppData\Local\Docker
    

4: Can I remove the AppData\Local\Docker directory?

Answer:

Yes, if Docker Desktop is uninstalled and docker-desktop WSL distros are removed via:

wsl --unregister docker-desktop
wsl --unregister docker-desktop-data

Then it's safe to delete:

C:\Users\<You>\AppData\Local\Docker

5: How to find unnecessary files that can be deleted in AppData\Local?

Answer:

Look for:

  • Orphaned folders from uninstalled apps
  • Cache/log/temp folders

You can safely delete:

  • AppData\Local\Temp
  • Folders of uninstalled apps

Use PowerShell to list large folders:

Get-ChildItem "$env:LOCALAPPDATA" -Directory |
Sort-Object { (Get-ChildItem $_.FullName -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum } -Descending |
Select-Object Name, @{Name="SizeMB";Expression={[math]::Round(($_ | Get-ChildItem -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum / 1MB, 2)}}

6: I see a lot of space taken by AppData\Local\Packages, how to optimize that?

Answer:

Do the following:

  1. Identify large folders:

    Get-ChildItem "$env:LOCALAPPDATA\Packages" -Directory |
    Sort-Object { (Get-ChildItem $_.FullName -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum } -Descending |
    Select-Object Name, @{Name="SizeMB";Expression={[math]::Round(($_ | Get-ChildItem -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum / 1MB, 2)}}
  2. Delete leftover folders from uninstalled Store apps.

  3. Use Windows Settings > Apps > Installed Apps to reset or uninstall unused apps.

  4. Manually clear cache from:

    • LocalCache
    • TempState
  5. Use Disk Cleanup or Storage Sense to remove Delivery Optimization Files.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment