Skip to content

Instantly share code, notes, and snippets.

View mcdaqc's full-sized avatar
:octocat:
Focusing

David Quispe mcdaqc

:octocat:
Focusing
View GitHub Profile
@mcdaqc
mcdaqc / gist:563c7a92af8da9d911b4f358858d8504
Last active February 12, 2025 01:08
Shrink WSL2 and Docker Virtual Disks to Reclaim Disk Space

Shrink WSL2 and Docker Virtual Disks to Reclaim Disk Space

Over time, WSL2 distributions and Docker images can consume significant disk space. Even after deleting files, the allocated virtual disk (VHDX) does not automatically shrink. This guide explains how to manually reclaim disk space by optimizing the virtual disk.

Shrinking WSL2 Virtual Disks

Locate the VHDX File

On Windows 11, WSL2 distributions store their virtual disks in the following location:

var cover = document.createElement("div");
let css = `
position: fixed;
pointer-events: none;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: white;
mix-blend-mode: difference;