Search for the highest sized file in the mount point. Useful while dealing with full mount points and cleaning up files to free up space.

There are many instances in the life of sysadmin when his system starts throwing filesystem full events and its headache to search culprit. Here we are going to see a command to search and display files with high utilization in a mount point. This is very useful to dig down and target exactly huge/big files rather than wasting time on trimming/deleting small files.
For example, if you are facing /tmp is full. Below is the command to search for large files in the given mount point. Here we are using du i.e. disk usage command then sorting the output list in reverse order so that the highest size files come to the top. Then getting top 10 to display as a result.
# du -a /tmp | sort -nr | head -n 10 3396448 /tmp 1801984 /tmp/Acasrro411704 994848 /tmp/software.depot 81088 /tmp/PACPTHP_00001.depot 77088 /tmp/OraInstall2008-03-19_09-39-20AM 76912 /tmp/OraInstall2008-03-19_10-15-28AM 76848 /tmp/OraInstall2008-03-19_09-39-20AM/jre/1.4.2 76848 /tmp/OraInstall2008-03-19_09-39-20AM/jre 76656 /tmp/OraInstall2008-03-19_10-15-28AM/jre/1.4.2 76656 /tmp/OraInstall2008-03-19_10-15-28AM/jre
Replace /tmp with a mount point of your choice while running it in your system.
There are also different ways you can trace the highest size hogger on a mount point. Below are few
To find the large file size above 5000
# find /var -xdev -size +5000 /var/opt/perf/datafiles/logglob /var/opt/perf/datafiles/logproc /var/opt/perf/datafiles/logdev /var/opt/perf/datafiles/logtran /var/opt/OV/log/SPISvcDisc/DBSPI_ORACLE_UNIX_discovery.trc /var/opt/OV/log/osspi/osspi.log ----- output truncated -----
Top 10 large directories in the mount point
# du -kx /var | sort -rn -k1 | head -n 10 6726048 /var 3962830 /var/opt 3471340 /var/opt/OV 2494362 /var/adm 2465390 /var/opt/OV/tmp 1512210 /var/opt/OV/tmp/OpC 1438642 /var/adm/openv/logs 1438642 /var/adm/openv 921030 /var/adm/sa 822672 /var/adm/openv/logs/bpdbm
Top 10 large files in the mount point
# find /var -type f -xdev -print | xargs -e ll | sort -rn -k5 | head -n 10 -rw-rw---- 1 root bin 1463238440 Nov 1 14:45 /var/opt/OV/tmp/OpC/msgagtdf -rw-rw-r-- 1 root bin 944541567 Nov 1 14:52 /var/opt/OV/tmp/sqlnet.log -rw-rw-rw- 1 oracle92 dba 307369984 Mar 5 2014 /var/opt/omni/tmp/rcvcat21945.exp -rw------- 1 root mail 187848937 Nov 1 14:01 /var/tmp/dead.letter -rw-rw---- 1 root bin 84680704 Feb 16 2013 /var/opt/OV/tmp/OpC/msgagtdf-11975.gc -rw-r--r-- 1 root bin 80937879 Nov 1 14:54 /var/opt/OV/log/osspi/osspi.log -rwxrwxrwx 1 root users 58566204 Nov 1 14:55 /var/adm/rrdtool/apcrss32.rrd -rw-rw-r-- 1 root bin 55159884 May 25 2009 /var/opt/OV/installation/temp/bbc/fx/upload/DeplM22799 -rw-rw-r-- 1 root bin 55159884 May 18 2009 /var/opt/OV/installation/temp/bbc/fx/upload/DeplM22011 -rw-rw-r-- 1 root bin 55159884 Jun 30 2010 /var/opt/OV/installation/temp/bbc/fx/upload/DeplM10143
Share Your Comments & Feedback: