"The term 'wslcompact' is not recognized as the name of a cmdlet, function, script file, or operable
program."
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
"The term 'wslcompact' is not recognized as the name of a cmdlet, function, script file, or operable
program."
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.
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.
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.
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<username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_<version>\LocalState\rootfs\ext4.vhdx
**Use code with caution.**
I hope this information will help. Please let me know if you have any other queries.
Good day