<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ariful Anik</title>
    <description>The latest articles on DEV Community by Ariful Anik (@xettabyte).</description>
    <link>https://dev.to/xettabyte</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F857960%2F9d1fada6-f289-402e-a5df-630ec90d0ceb.jpg</url>
      <title>DEV Community: Ariful Anik</title>
      <link>https://dev.to/xettabyte</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xettabyte"/>
    <language>en</language>
    <item>
      <title>Why your WSL disk never shrinks (and why Windows Home makes it worse)</title>
      <dc:creator>Ariful Anik</dc:creator>
      <pubDate>Thu, 26 Nov 2026 19:41:11 +0000</pubDate>
      <link>https://dev.to/xettabyte/why-your-wsl-disk-never-shrinks-and-why-windows-home-makes-it-worse-502g</link>
      <guid>https://dev.to/xettabyte/why-your-wsl-disk-never-shrinks-and-why-windows-home-makes-it-worse-502g</guid>
      <description>&lt;p&gt;My C: drive was nearly full. Explorer said &lt;code&gt;C:\WSL\Ubuntu\ext4.vhdx&lt;/code&gt; was &lt;strong&gt;70 GB&lt;/strong&gt;. Inside Linux, &lt;code&gt;df -h&lt;/code&gt; said &lt;strong&gt;40 GB&lt;/strong&gt; used.&lt;/p&gt;

&lt;p&gt;Thirty gigabytes of nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The file that only grows
&lt;/h2&gt;

&lt;p&gt;WSL 2 keeps each distro in a virtual disk, &lt;code&gt;ext4.vhdx&lt;/code&gt;. When Linux writes data, the file grows. When you delete files inside Linux, the space is freed &lt;em&gt;inside&lt;/em&gt; the filesystem, but the &lt;code&gt;.vhdx&lt;/code&gt; file on Windows keeps its size. After months of &lt;code&gt;npm install&lt;/code&gt;, &lt;code&gt;pip install&lt;/code&gt;, Docker builds and VS Code server updates, the gap gets big.&lt;/p&gt;

&lt;p&gt;This is a well-known issue: &lt;a href="https://github.com/microsoft/WSL/issues/4699" rel="noopener noreferrer"&gt;microsoft/WSL#4699&lt;/a&gt; has over 1,400 reactions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the usual fixes don't work for everyone
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Optimize-VHD&lt;/code&gt; isn't on Windows Home.&lt;/strong&gt; Most guides tell you to run &lt;code&gt;Optimize-VHD -Mode Full&lt;/code&gt;. That cmdlet is part of the Hyper-V PowerShell module, which only exists on Pro, Enterprise and Education with Hyper-V enabled. On Home, the command simply doesn't exist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sparse mode isn't the answer yet.&lt;/strong&gt; Newer WSL has &lt;code&gt;wsl --manage &amp;lt;distro&amp;gt; --set-sparse true&lt;/code&gt;, which is supposed to release space automatically. It's experimental, off by default, and was disabled for a while after reports of corruption. Worse: once a disk is sparse, &lt;code&gt;Optimize-VHD&lt;/code&gt; and &lt;code&gt;compact vdisk&lt;/code&gt; refuse to touch it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deleting files alone does nothing for C:.&lt;/strong&gt; You have to compact the file afterwards, with WSL fully shut down.&lt;/p&gt;

&lt;h2&gt;
  
  
  The manual fix that works everywhere
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;diskpart&lt;/code&gt; ships with every edition of Windows, including Home:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# inside the distro: free space, then tell the disk which blocks are free&lt;/span&gt;
sudo apt-get clean
rm -rf ~/.cache/pip ~/.npm/_cacache
sudo fstrim -av
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="c1"&gt;# in Windows, as administrator&lt;/span&gt;
&lt;span class="n"&gt;wsl&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;shutdown&lt;/span&gt;
&lt;span class="n"&gt;diskpart&lt;/span&gt;
&lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;vdisk&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"C:\path\to\ext4.vhdx"&lt;/span&gt;
&lt;span class="n"&gt;attach&lt;/span&gt; &lt;span class="n"&gt;vdisk&lt;/span&gt; &lt;span class="n"&gt;readonly&lt;/span&gt;
&lt;span class="n"&gt;compact&lt;/span&gt; &lt;span class="n"&gt;vdisk&lt;/span&gt;
&lt;span class="n"&gt;detach&lt;/span&gt; &lt;span class="n"&gt;vdisk&lt;/span&gt;
&lt;span class="k"&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The trap: not everything in ~/.cache is cache
&lt;/h2&gt;

&lt;p&gt;"Just delete &lt;code&gt;~/.cache&lt;/code&gt;" is common advice. On a developer machine it can hurt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;~/.cache/huggingface/token&lt;/code&gt;: your Hugging Face login&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;~/.cache/gh&lt;/code&gt;, &lt;code&gt;~/.cache/claude&lt;/code&gt;: CLI auth and state&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;~/.cache/deno/location_data&lt;/code&gt;: Deno KV databases and localStorage&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;~/.cache/pypoetry/virtualenvs&lt;/code&gt;: every Poetry project's environment&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;~/.cache/lm-studio&lt;/code&gt;: multi-GB local AI models&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And on the Docker side, &lt;code&gt;docker volume prune&lt;/code&gt; on an old Docker version (or anonymous volumes of a stopped &lt;code&gt;postgres&lt;/code&gt; container) can delete database data.&lt;/p&gt;

&lt;h2&gt;
  
  
  I automated it, carefully
&lt;/h2&gt;

&lt;p&gt;I got tired of doing this by hand, so I wrote &lt;strong&gt;&lt;a href="https://github.com/4riful/wslim" rel="noopener noreferrer"&gt;wslim&lt;/a&gt;&lt;/strong&gt;, a small open-source Windows tool (one 120 KB exe, no install, works on Home):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0q7ujp58p4xib26ea7e3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0q7ujp58p4xib26ea7e3.png" alt="wslim scan result" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Find&lt;/strong&gt;: reads your WSL distros and their &lt;code&gt;.vhdx&lt;/code&gt; files from the registry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scan&lt;/strong&gt;: pipes a rule catalog (a POSIX &lt;code&gt;sh&lt;/code&gt; script) into each distro. Each finding gets a tier:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;safe&lt;/strong&gt;: rebuilds itself (npm/pip/uv caches, old Claude Code and VS Code server builds, Docker build cache). Ticked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;review&lt;/strong&gt;: can be rebuilt but costs time or bandwidth (Go modules, Hugging Face models, unused Docker images). Not ticked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;never touched&lt;/strong&gt;: Docker named volumes, databases, project source, &lt;code&gt;~/.config&lt;/code&gt;, keys, logins.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean&lt;/strong&gt;: deletes a path only if it was in the scan you saw, you ticked it, and the rule still matches it now.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shrink&lt;/strong&gt;: asks before stopping WSL, then runs &lt;code&gt;diskpart compact vdisk&lt;/code&gt; behind one UAC prompt.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On my machine: &lt;strong&gt;69.8 GB → 42.6 GB&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;There's a command-line version too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wslim&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;cli&lt;/span&gt; &lt;span class="n"&gt;scan&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="n"&gt;wslim&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;cli&lt;/span&gt; &lt;span class="n"&gt;clean&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;preview&lt;/span&gt;
&lt;span class="n"&gt;wslim&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;cli&lt;/span&gt; &lt;span class="n"&gt;clean&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;shrink&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install with Scoop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;scoop&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="mi"&gt;4riful&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;4riful&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;scoop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;
&lt;span class="n"&gt;scoop&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;wslim&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or grab the exe from &lt;a href="https://github.com/4riful/wslim/releases/latest" rel="noopener noreferrer"&gt;Releases&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The rules live in one file and are documented in &lt;a href="https://github.com/4riful/wslim/blob/main/docs/RULES.md" rel="noopener noreferrer"&gt;docs/RULES.md&lt;/a&gt;. &lt;strong&gt;What eats space in your distros?&lt;/strong&gt; I'd love rule suggestions, as comments here or as issues on GitHub.&lt;/p&gt;

</description>
      <category>wsl</category>
      <category>windows</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
