I use Docker Desktop on Windows to run local AI, such as Ollama, Open-WebUI, Portainer, and even SwarmUi and Comfy-UI. Because of that, I’m regularly growing and shrinking the number of AI models on my drive and that’s a lot of GB of storage! Recently I noticed less than 15% storage remaining on my SSD and thanks to SequoiaView, I realized it was because Ubuntu was getting huge! So here’s how I solved the problem.
Manual Cleanup
First, delete the things that you don’t use any more. If you have models you haven’t run in a good long while, delete them. If you have Docker volumes, images, or containers that are unused, remove them. Clean up your (digital) room!
Empty the Recycling Bin, Linux Style
Courtesy of this AskUbuntu post, in the Ubuntu terminal you can run the command:
rm -rf ~/.local/share/Trash/* |
However, later in that same post there is also a quick program to install that makes this easier:
sudo apt install trash-cli trash-empty |
Compress Ubuntu
WSL2 is designed to grow, not shrink, so there are extra steps involved. First and foremost, you will be opening Windows Powershell instead of the Ubuntu terminal. Shutdown WSL: wsl --shutdown
Use File Explorer to find the exact path to your distribution: \Users\
.
Right-click on the ext4.vhdxfile, choose Properties, and then copy the full path to the file.
Finally, go to your windows Powershell and run each line of the following commands separately:
diskpart select vdisk file="C:\<YOUR_PATH_GOES_HERE>\ext4.vhdx" compact vdisk |
It should start compressing immediately with updates on its progress (this took ~ 1 minute for me).
Restart WSL2
Time to start WSL back up and bask in your newly recovered free space.
wsl -d Ubuntu
Sources
Figured this out thanks to the following posts:
- https://askubuntu.com/questions/468721/how-can-i-empty-the-trash-using-terminal (empty the trash)
- https://superuser.com/a/1823153 (compact Ubuntu)