Proposal: enable sparse mode by default
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.
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'.
/feature
Diagnostic information
Found '/feature', adding tag 'feature'
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 as far as I understand sparse mode is incomplete. It does not call ioctl FSCTL_SET_ZERO_DATA for vhd regions being deallocated
@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?