IssueRaiser

WSL 2 should automatically release disk space back to the host OS

**Is your feature request related to a problem? Please describe.** I occasionally have workloads that consume large amounts of disk space for temporary use in `/tmp`. For example, transcoding large video files or processing large datasets exported from a database. Since WSL2 stores its filesystem on a `.vhdx`, that file grows when the dataset is processed and never releases that space. Also, it doesn't appear to re-use released disk space in the `.vhdx` when files are deleted... it seems to prefer to grow the file rather than re-use existing empty space. (I haven't explicitly tested that theory, but my workload deletes temporary files as they are used and I never had enough of them existing simultaneously to reach 250GB, but the size of the `.vhdx` eventually expanded to that size. When I'm done with that workload, I have to: ``` wsl --shutdown optimize-vhd -Path .\ext4.vhdx -Mode full ``` This is annoying since it basically means that my system backups include a huge `.vhdx` file that is mostly empty. Also, until about 2 weeks ago, it was consuming the entire remainder of my system disk. I had only 50GB free, which was enough to handle the workload, but since it continued to grow even after files were removed, that didn't matter. (I figured it was time to upgrade the disk size anyway) **Describe the solution you'd like** Automatic compaction of the `.vhdx`, or a way to do so while WSL2 is still running so that I can schedule it for frequent cleanups. **Describe al

Posted by dsmaher on Nov 20, 2019, 2:00 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

github (Other)

WSL 2 should automatically release disk space back to the host OS

dsmaherNov 20, 2019, 2:00 PM

**Is your feature request related to a problem? Please describe.** I occasionally have workloads that consume large amounts of disk space for temporary use in `/tmp`. For example, transcoding large video files or processing large datasets exported from a database. Since WSL2 stores its filesystem on a `.vhdx`, that file grows when the dataset is processed and never releases that space. Also, it doesn't appear to re-use released disk space in the `.vhdx` when files are deleted... it seems to prefer to grow the file rather than re-use existing empty space. (I haven't explicitly tested that theory, but my workload deletes temporary files as they are used and I never had enough of them existing simultaneously to reach 250GB, but the size of the `.vhdx` eventually expanded to that size. When I'm done with that workload, I have to: ``` wsl --shutdown optimize-vhd -Path .\ext4.vhdx -Mode full ``` This is annoying since it basically means that my system backups include a huge `.vhdx` file that is mostly empty. Also, until about 2 weeks ago, it was consuming the entire remainder of my system disk. I had only 50GB free, which was enough to handle the workload, but since it continued to grow even after files were removed, that didn't matter. (I figured it was time to upgrade the disk size anyway) **Describe the solution you'd like** Automatic compaction of the `.vhdx`, or a way to do so while WSL2 is still running so that I can schedule it for frequent cleanups. **Describe al

Comments (0)

No comments yet. Start the discussion.

Comment on this issue