WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Proposal: enable sparse mode by default

Open soredake opened this issue 6 months ago • 6 comments

Is your feature request related to a problem? Please describe. Currently, WSL does not enable NTFS sparse file support by default for its virtual disk (ext4.vhdx). This leads to unnecessary disk space usage, especially when working with large development environments, package managers, or Docker images. Users must manually convert or recreate the VHDX in sparse mode to benefit from actual disk savings.

Describe the solution you'd like Enable sparse mode by default when creating new WSL distributions or VHDX disks. This would ensure that unused or zeroed blocks inside the VHDX do not consume physical disk space unnecessarily. Ideally, this should be transparent to the user and require no additional setup.

Describe alternatives you've considered wsl --manage <distro> --set-sparse true --allow-unsafe

Additional context Sparse support can significantly reduce the disk footprint for users working with data-heavy tools like Docker, compilers, and large codebases. As SSDs remain relatively expensive and WSL is used heavily in developer workflows, enabling sparse mode by default would be a smart default.

soredake avatar Jul 09 '25 10:07 soredake

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

github-actions[bot] avatar Jul 09 '25 10:07 github-actions[bot]

/feature

soredake avatar Jul 09 '25 10:07 soredake

Diagnostic information
Found '/feature', adding tag 'feature'

github-actions[bot] avatar Jul 09 '25 10:07 github-actions[bot]

Agreed, we would like to enable sparse mode by default. Right now we are still seeing quality reports and issues with sparse VHDs and so have made it an opt in experimental feature. We're investigating how to improve our storage story in the future!

craigloewen-msft avatar Jul 14 '25 21:07 craigloewen-msft

@craigloewen-msft as far as I understand sparse mode is incomplete. It does not call ioctl FSCTL_SET_ZERO_DATA for vhd regions being deallocated

dporf avatar Nov 13 '25 08:11 dporf

@soredake

Sparse support can significantly reduce the disk footprint

It could if it worked but it does not (see issue #12103 for example). May be you know how it may be configured to actually work?

dporf avatar Nov 14 '25 07:11 dporf