Disk Usage issues
Hossam Moghazy
Unix and Storage Head at Industrial Development and Workers Bank of Egypt
Disk Usage
df reports disk space on filesystems:
df --help
du reports disk usage of directory contents:
du --help
ncdu reports disk usage of directory contents in a gui-like ncurses interface, and allows sorting:
ncdu -h
Troubleshooting
Report disk usage on all filesystems
df -h
Analyze disk usage of a directory
With ncdu use s key to toggle ascending and descending sort by size. For example, report disk usage for the root directory:
ncdu /
Unlike ncdu, the output from du is not sorted, and if a directory has a lot of content then the output can be unwieldy. However, the output can be tamed with a bit of help from grep, sort and head.
For example, show human readable totals for subdirectories that are taking up gigabytes of space in root directory, and reverse sort by number; use -a to include the files in the directory, -h for human readable, and -x to skip directories on different filesystems:
du -hax --max-depth=1 / | grep '[0-9]G' | sort -nr
Rather than manually drilling down through each directory in turn, an alternative approach is to analyze the files in each directory, ignoring the subdirectories. For example, to find out which directories are the largest by just counting the size of their files; excluding the size of subdirectories (-S):
du -Sx / | sort -nr | head -n 10
To get a human readable size for an individual directory:
du -hs /tmp
another solution that you may find open files as we mentioned before in previous post about lsof
you can enter the desired dire then make lsof or you can make lsof | grep deleted to catch deleted files then kill the process