My Disk is full. How can I find the location of the largest usage?

Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"

Top Level » System Level » File System

My Disk is full. How can I find the location of the largest usage?Last Modified: Dec 3, 2017, 3:31 pm
1) Before starting, confirm which partitions you have, and which of them are full:

df -h

If you have many partitions, eg: for /home, /var, /usr, etc... then you can narrow down the search by only searching the affected partition, to make the process go much quicker.

The method to hunt down files, is to use the "du" command, and sort the output.
Note, this process can be slow, so be patient.

2) I typically start with suspect paths, but if you've already narrowed it down to a partition, start there, eg:

cd /var
du | sort -n

after /var, I would check /usr

cd /usr
du | sort -n

and following that /home, and /etc, in the same manner.

3) If you're not having any luck, then you can try searching the / partition.
This will count all files on the box, so if your disk is slow/spinny, then this may take a very long time.

cd /
du | sort -n

4) If you want to search all of /, but you don't want other partitions (/var or /home, etc..) to be included.. (assuming those are actually separate partitions, as found in #1), then you can add the -x option, to stay on this partition, and don't traverse the other sub-partitions:

cd /
du -x | sort -n

For all of the above du commands, with the sort option, the largest paths will show up at the bottom of the output.
The way this works, is that all of the files have to be found and loaded first.. and once loaded, the the sort starts up.
No output will be displayed until the full list is loaded, so be very patient.   You can ctrl-c and try a sub-path if you want to be more specific, which should run more quickly.

ncdu is another simple tool to help track down disk usage:
It can be installed with common package managers, eg:

yum install ncdu

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST