GuidesIdentifying Disk Space

Identifying Disk Space

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Even the largest disks will eventually begin to fill up, and sometimes you notice this (or at least, I do!) only when strange errors start to occur. If you’re seeing odd errors, however, it’s always worth starting with df -h to quickly check out whether there’s a disk space problem.

When disks fill up, strange errors occur. Determine if and where you have a disk space shortage, and learn how to resolve it.

If you do have less space than you thought, the next stage is to work out where it’s being used. The basic option is the command-line utility du:

du -sh /*

This shows you a summary of what’s in each of your top-level directories.
The -s option summarizes each directory, and -h gives the
sizes in human-readable form (i.e., in KB, MB, and GB rather than in bytes).
Once you’ve identified the particularly large directories, you can drill down
to check them out further, for example:

du -sh /var/*

Use the -I option to exclude particular directories:

du -I ".svn" -sh *

This will ignore all files or directories that match the .svn pattern. You can also use wildcards, for example

du -I "pub*" -sh *

To limit your search to only directories that have at least a few gigabytes of data, use grep:

du -sh /* | grep G

However, drilling down with du can be a long, slow process. There are also graphical options available for different platforms, such as Filelight for Linux and DasiyDisk for Mac. I gave DaisyDisk a go on my rapidly-filling-up laptop, and found that the ease of clicking through the layers was particularly useful for the “deep” directory structures in my music/video directories. But du had already helped me get rid of 5 GB by showing me a surprising heap of stuff in my downloads directory; so the old-school console option does do the job too!

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of “Linux System Administration Recipes: A Problem-Solution Approach” (Apress, 2009).

Follow ServerWatch on Twitter

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories