reduce disk space consumption for WSL

The wsl is consuming too much disk space so I look up and tried to compact the ext4.vhdx but it didn't work like the instructions. I really need some supports to this problems.

Hi Khanh,
I am Tanvi, and I would be happy to assist you today!

WSL2 uses a dynamic VHDX file (ext4.vhdx), which grows as you use it but doesn't automatically shrink when you delete files. 1 This can lead to significant disk space consumption over time.


WSLcompact Utility- This tool is designed to compact WSL2 VHDX files efficiently.
Steps:
Open PowerShell as an administrator.
Run the following command, replacing ext4.vhdx with the actual path to your VHDX file:
PowerShell

wslcompact C:\Users\

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

"The term 'wslcompact' is not recognized as the name of a cmdlet, function, script file, or operable

program."

4 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

While wslcompact is not a standard command, you can use other methods to optimize the VHDX file:

Optimize-VHD-
1. Open PowerShell as an administrator.
2. Navigate to the directory containing the ext4.vhdx file.
3. Run the following command:
4. PowerShell

Optimize-VHD -Path .\ext4.vhdx -Mode full

Additionally, if you're comfortable with disk management tools, you can try shrinking the VHDX file to match the space used. However, this is a more advanced operation and requires caution.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

First, the command Optimize-VHD -Path .\ext4.vhdx -Mode full didn't work though I opened shell as admin and navigated to the disk directory. And I think I find out what continuously consumps my storage. WSL keeps generate the files called RdclientAutoTrace even I didn't use wsl, each one is 10 Mb and it keeps generated every minutes as long as my PC is not shutdown (consumps around 5Gb storage last 4-5 days). I'm currently searching for this problem, would be great if you can support me to solve these problems.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hi Khanh,
Double-check the path to your ext4.vhdx file. Ensure you're in the correct directory and the path is accurate. There's a possibility of corruption in the VHDX file.
You might need to check its integrity using tools like chkdsk or fsck.

Secondly, RdclientAutoTrace files are typically related to Remote Desktop Connection (RDC) tracing. While WSL can sometimes interact with RDC components, it's unusual to generate these files continuously.

Check if RDC tracing is enabled on your system. Disabling it might prevent the creation of these files.

Try temporarily disabling WSL to see if the file generation stops. This can help isolate the issue.

I hope this will resolve your issue. Have a good day.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I copy and check the path many times, still got this

Image

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I also found the same RdClient problems, tried to some work arounds but it still generates these files. The problems: https://github.com/microsoft/WSL/issues/10216. And how can I disable RDC like you said above?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I apologise for inconvenience but it would be great if you open a new case on Github wsl issues, since the experts there can help you more.
We here don't support wsl natively.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 25, 2025 Views 6,305 Applies to: