Hi chu,
Hope you're doing well.
You can try the following steps to free up disk space on your WSL2 virtual disk:
- Check the amount of disk space available in the VHD for a Linux distribution installed with WSL 2 by using the Linux Df command. To check available disk space, open a PowerShell command line and enter this command (replacing <distribution-name> with the actual distribution name):
"PowerShell wsl.exe --system -d <distribution-name> df -h /mnt/wslg/distro".
The output will include the total size of the disk, the amount of space currently being used, and the amount of space left in the VHD.
- If you see that you are near to reaching the available amount of disk space allocated to your VHD, or have already received an error due to no disk space remaining, you can expand the maximum amount of disk space allocated to the VHD associated with your Linux distribution.
- If you have deleted a large file in your Ubuntu system and the disk space has not been released, you can try to compact the VHDX file to reclaim disk space. You can use the "diskpart" tool to compact a VHDX file. This allows you to shrink a WSL2 virtual disk file, reclaiming disk space.
I hope this helps you resolve the issue. Let me know if you have any further questions.
Here are the relevant documents for your reference:
How to manage WSL disk space | Microsoft Learn
How to Shrink a WSL2 Virtual Disk – Stephen Rees-Carter (stephenreescarter.net)
windows 10 - How do I get back unused disk space from Ubuntu on WSL2? - Super User
wsl 2 - How to properly resize disk usage in docker desktop WSL2? - Stack Overflow
Best Regards,
Ian Xue
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.