Linux – How to show which process has disk space in Linux

How to show which process has disk space in Linux… here is a solution to the problem.

How to show which process has disk space in Linux

I ran these commands to determine disk space usage on my Linux system.

Used

file system size Avail Use% Mounted on/dev/mapper/foovg-foo 326G 202G 108G 66%/export/data/foo

du -sk * | awk '{sum += $1}END{print sum}'
132161064 ~ 126GB

So, the difference between 202G – 126G = 76G.

Where is 76G disk space?
How do I find out which process holds a file handle?
What is the deleted file name?

In Linux, the file descriptor under /proc/pid/fd/ is a soft link to the actual file.

Solution

Whether it is the cause or not, you can use LSOF to see which processes are keeping deleted files. Something like this might help:

lsof | grep '(deleted)$' | sort -rnk 7

In other words, grab all deleted files and sort them in descending order of size.

Related Problems and Solutions