AllTechWiki



A Place for All Technical Stuff Linux Cloud etc

Linux df -h showing wrong disk space


If you type df -h on any Linux/Unix servers showing wrong disk space utilization than du -sh .

Most probably df -h shows more utilization than du -sh.

Generally if you delete the files disk free space must increase but even though if you deleted many file still showing wrong space than normal utilization having the problem some where.

Let us discuss where the problem is below

If you delete the files in Linux OS, some running programs uses/open the those deleted files, so you have to find the files which are deleted and that are still in open by program.


To find out the list of Open Files in Linux 

you can use lsof -n command.

Find out the list of files which are deleted 


#lsof -n | grep deleted


[root@webserver-1 ~]# lsof -n | grep deleted

dbmrfc      440               lppadm    5w      REG             253,67        407               181001 /usr/app/APP/MS01/work/dev_rfc (deleted)
init.ohas  4246                 root    0r     FIFO             253,10        0t0              2138297 /var/tmp/.oracle/npohasd (deleted)
oacore     5592                 root   70u      REG             253,10       2576              3145860 /var/tmp/etilqs_25G5UzJq97Lf8nW (deleted)
oacore     5592                 root   71u      REG             253,10       2576              3223683 /var/tmp/etilqs_cncLskDINhIFUaQ (deleted)
oacore     5592                 root   72u      REG             253,10       2056              3223684 /var/tmp/etilqs_LKleswM6fx5x0En (deleted)
oacore     5592                 root   73u      REG             253,10       2056              3223686 /var/tmp/etilqs_qnTjds0MT21ARtO (deleted)
oacore     5592                 root   74u      REG             253,10       2048              3223687 /var/tmp/etilqs_hccycGDmxOOjxwf (deleted)
oacore     5592                 root   75u      REG             253,10       2576              3223694 /var/tmp/etilqs_K2xEv9GjVzvOrh0 (deleted)
oacore     5592                 root   76u      REG             253,10       2048              3223704 /var/tmp/etilqs_qkztxu8P8mFnGIW (deleted)
oacore     5592                 root   77u      REG             253,10       2576              3223705 /var/tmp/etilqs_vBtNiEoEheZxtdI (deleted)
oacore     5592                 root   78u      REG             253,10       3084              3223707 /var/tmp/etilqs_QPEh6brdRrwyfa3 (deleted)
oacore     5592                 root   79u      REG             253,10       2576              3223709 /var/tmp/etilqs_aToqd9iSYWKp3N3 (deleted)
oacore     5592                 root   80u      REG             253,10       3084              3224174 /var/tmp/etilqs_zyBTtzHookyesTI (deleted)
oacore     5592                 root   81u      REG             253,10       2056              3224175 /var/tmp/etilqs_EQpWL9GIFuqpa94 (deleted)
oacore     5592                 root   82u      REG             253,10      10240              3224176 /var/tmp/etilqs_6QUZNXwx0oFvxbv (deleted)
oacore     5592                 root   83u      REG             253,10       2048              3224179 /var/tmp/etilqs_dJNj5zOlvcRqrHd (deleted)
oacore     5592                 root   84u      REG             253,10       2576              3224189 /var/tmp/etilqs_bdoAYUJv7Gd29df (deleted)
oacore     5592                 root   85u      REG             253,10       2056              3224208 /var/tmp/etilqs_htI0bKLoQ2v3I9s (deleted)

[root@webserver-1~]# ps -ef | grep oacore
root      5592  4603  1 02:08 ?        00:20:10 /opt/OV/bin/oacore oacore /var/opt/OV/conf/oa/PipeDefinitions/oacore.xml
root     26573  1567  0 19:49 pts/3    00:00:00 grep --color=auto oacore


You will get the list of files which are still open by program.

Find out the program and restart the service.

Example:

One of my Apache web server is having the similar kind of issue.

when I checked with lsof -n | grep deleted command shows many files which are already deleted but still are in open by the Apache.

Solution : 

We have to restart the server or restart the service.

Note: Rebooting the server is not good practice , so we can restart the application or KILL the process.

After killing the process or restart the service its shows the correct disk space.



Post a Comment

Previous Post Next Post

Basic Useful Links