KEMBAR78
fix: correct sparse VHD command to include `true` by junhaoliao · Pull Request #13512 · microsoft/WSL · GitHub
Skip to content

Conversation

@junhaoliao
Copy link
Contributor

@junhaoliao junhaoliao commented Sep 23, 2025

Summary of the Pull Request

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

(closes #13075)

The WSL --set-sparse command requires a boolean value (true or false). The current "MessageSparseVhdDisabled" prompt omits true, which causes confusing error messages and prevented sparse VHD from being enabled.

This change ensures the command is complete in the "MessageSparseVhdDisabled" prompt:

  wsl.exe --manage <Distro> --set-sparse true --allow-unsafe

Validation Steps Performed

Ran .\bin\x64\Debug\test.bat /name:SimpleTests::SimpleTests::CheckSparse and observed the test case passed:

PS C:\Users\junhao\CLionProjects\WSL> .\bin\x64\Debug\test.bat /name:SimpleTests::SimpleTests::CheckSparse
Test Authoring and Execution Framework v10.97k for x64
OS build string: 26100.1.amd64fre.ge_release.240331-1435
Verify: IsTrue(config.good())
Verify: IsNotNull(g_WatchdogTimer)
Running test setup command: Powershell         -NoProfile         -ExecutionPolicy Bypass         -Command "C:/Users/junhao/CLionProjects/WSL\tools\test\test-setup.ps1 -Version '2' -DistroPath C:/Users/junhao/CLionProjects/WSL/packages/Microsoft.WSL.TestDistro.2.5.7-47/test_distro.tar.xz -DistroName test_distro -Package 'C:/Users/junhao/CLionProjects/WSL/bin/x64\Debug\installer.msix' -UnitTestsPath C:/Users/junhao/CLionProjects/WSL\test\linux\unit_tests -AllowUnsigned"
Removing previous package installation
Removing MSI package: {50D135E3-FC56-4CD3-A278-D5CD3B95DB3D}
Installing package: C:/Users/junhao/CLionProjects/WSL/bin/x64\Debug\installer.msix
WSL is finishing an upgrade...
Unregistering.
The operation completed successfully.

The operation completed successfully.
The operation completed successfully.
Verify: IsTrue(SetEnvironmentVariableW(L"WSL_UTF8", L"1"))
Verify: AreEqual(LxsstuInitialize(FALSE), TRUE)

StartGroup: SimpleTests::SimpleTests::CheckSparse
Verify: IsTrue(config.good())
Restarting WSLService
Verify: IsNotNull(manager)
Verify: IsNotNull(service)
tar C:\Users\junhao\AppData\Local\Temp\s1fd4.0.tar
vhdDir C:\Users\junhao\AppData\Local\Temp\s1fd4.1
Verify: IsTrue(std::filesystem::create_directory(vhdDir))
Export in progress, this may take a few minutes. (408 MB)

The operation completed successfully.
Verify: AreEqual(LxsstuLaunchWsl(std::format(L"{} {} {}", WSL_EXPORT_ARG, LXSS_DISTRO_NAME_TEST, tar.wstring()).c_str()), (DWORD)0)
Unregistering.
There is no distribution with the supplied name.
Error code: Wsl/Service/WSL_E_DISTRO_NOT_FOUND
Verify: AreEqual(ExpectedOutput, output)
Verify: AreEqual(ExpectedWarnings, warnings)
Verify: IsFalse(attributes == INVALID_FILE_ATTRIBUTES)
Verify: IsTrue(WI_IsFlagSet(attributes, FILE_ATTRIBUTE_SPARSE_FILE) == sparse)
Verify: AreEqual(0u, LxsstuLaunchWsl(WSL_SHUTDOWN_ARG))
Verify: AreEqual(ExpectedOutput, output)
Verify: AreEqual(ExpectedWarnings, warnings)
Verify: IsFalse(attributes == INVALID_FILE_ATTRIBUTES)
Verify: IsTrue(WI_IsFlagSet(attributes, FILE_ATTRIBUTE_SPARSE_FILE) == sparse)
Verify: AreEqual(ExpectedOutput, output)
Verify: AreEqual(ExpectedWarnings, warnings)
Verify: IsFalse(attributes == INVALID_FILE_ATTRIBUTES)
Verify: IsTrue(WI_IsFlagSet(attributes, FILE_ATTRIBUTE_SPARSE_FILE) == sparse)
Verify: AreEqual(ExpectedOutput, output)
Verify: AreEqual(ExpectedWarnings, warnings)
Verify: IsFalse(attributes == INVALID_FILE_ATTRIBUTES)
Verify: IsTrue(WI_IsFlagSet(attributes, FILE_ATTRIBUTE_SPARSE_FILE) == sparse)
Unregistering.
The operation completed successfully.

Verify: IsTrue(config.good())
Restarting WSLService
Verify: IsNotNull(manager)
Verify: IsNotNull(service)
EndGroup: SimpleTests::SimpleTests::CheckSparse [Passed]
Verify: IsTrue(SetEnvironmentVariableW(L"WSL_UTF8", nullptr))
Exiting UnitTests module
Restoring .wslconfig
Verify: IsTrue(config.good())
Previous default distro doesn't exist anymore: '{08d1a45a-41d8-4048-9c92-e9a7bb92e431}', skipping restore

Summary: Total=1, Passed=1, Failed=0, Blocked=0, Not Run=0, Skipped=0

@junhaoliao
Copy link
Contributor Author

@microsoft-github-policy-service agree

Copy link
Member

@benhillis benhillis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only file you need to modify, the rest are auto-generated.

@junhaoliao
Copy link
Contributor Author

Thanks for the review!

This is the only file you need to modify, the rest are auto-generated.

Sorry if i get your comment wrong - I suppose you mean only localization/strings/en-US/Resources.resw needs to be modified, so i reverted the changes on the other localization files: 01f44a8

@OneBlue
Copy link
Collaborator

OneBlue commented Sep 29, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@junhaoliao
Copy link
Contributor Author

i see the Azure workflow fails. now i understand how the translation automation works, i can debug and test locally. just a moment before i push the fix

wsl.exe --manage &lt;DistributionName&gt; --set-sparse --allow-unsafe</value>
<comment>{Locked="--manage "}{Locked="--set-sparse "}{Locked="--allow-unsafe"}Command line arguments, file names and string inserts should not be translated</comment>
wsl.exe --manage &lt;DistributionName&gt; --set-sparse true --allow-unsafe</value>
<comment>{Locked="--manage "}{Locked="--set-sparse true "}{Locked="--allow-unsafe"}Command line arguments, file names and string inserts should not be translated</comment>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run: python tools\devops\validate-localization.py --fix locally to format this, this should unblock the CI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the misunderstanding in the Locked syntax. the issue should now be fixed by running the script as you suggested

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PR should be ready for review. please help running the pipeline again

@junhaoliao
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 13512 in repo microsoft/WSL

@OneBlue
Copy link
Collaborator

OneBlue commented Sep 30, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 1, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@junhaoliao
Copy link
Contributor Author

@benhillis Merging is blocked and it seems your re-review is needed. Would you mind taking a look again?

@benhillis benhillis merged commit 98f4960 into microsoft:master Oct 1, 2025
6 checks passed
@benhillis
Copy link
Member

Thank you for your contribution!

@junhaoliao junhaoliao deleted the set-sparse-true branch October 1, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sparse VHD support is currently disabled due to potential data corruption.

3 participants