Cleaning Drives
This document should help you clean up drives that are running low on space.
Windows
- Tree Size Free can be used to analyze disk usage, allowing users to easily find locations that are using the most storage. Note that the free version shouldn't be used on Windows Server.
WSL
These instructions were adapted from the second-top response in this StackOverflow post
The entirety of storage used by a WSL distro appears as a single vdx drive in Tree Size and special steps need to be taken to shrink the volume.
Clean up contents of the WSL Distro using the steps in the following Linux section.
Stop Docker on your Windows machine, if it's running.
Stop WSL instances with the command
wsl --shutdownCreate a file called
compact-disk.txtwith the following contents, making sure you reference the proper path instead of "CanonicalGroupLimited.UbuntuXX.NNNNNN":select vdisk file="C:\Users\%username%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuXX.NNNNNN\LocalState\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdiskOpen an Admin Powershell instance
Change directory to the previously created file
Run the command
diskpart /s compact-disk.txt
The final command will take a while to complete; up to an hour for very large drives.
Linux
du -ha | grep -P '^\S+G\s'
The du command can take a long time to run, so it's best to break up your disk usage analysis into smaller bites. For the most part, you will only need to check for disk usage in users' home directories, but there might be edge cases where you should look in other locations as well.
You can use the command du -ha | grep -P '^\S+G\s' to list disk usage in the current directory and filter out everything that isn't at least 1 GB in size (that's the grep modifier).
The output might look like this:
2.9G ./.virtualenvs
1.5G ./git/projects/aptim/chama22/chama_django/database/db.sqlite3
1.5G ./git/projects/aptim/chama22/chama_django/database
1.5G ./git/projects/aptim/chama22/chama_django
2.4G ./git/projects/aptim/chama22
3.4G ./git/projects/aptim
1.1G ./git/projects/epa/scinote-web/node_modules
1.5G ./git/projects/epa/scinote-web
1.1G ./git/projects/epa/old_scinote
1.8G ./git/projects/epa/ordscinote
5.4G ./git/projects/epa
1.1G ./git/projects/maiawater
12G ./git/projects
1.2G ./git/documentation/projects
1.5G ./git/documentation
1.7G ./git/gqc/shiny-react-testbeds/node_modules
1.9G ./git/gqc/shiny-react-testbeds
1.4G ./git/gqc/project-docs
1.2G ./git/gqc/deepvibe-super-repo
7.9G ./git/gqc
21G ./git
28G .
Common directories to consider purging might be:
- Old or unused git repositories
- Old or unused Python virtual environments
.cache/directory contentDownloads/directory content