When df and du are contradictory

I encountered a situation today where du reported a usage of 520K whereas df reported a occupation of 34G.

[root@server httpd]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdc1 40G 34G 3.5G 91% /var/log/httpd
[root@server httpd]# pwd; du-hs
/var/log/httpd
2.9M .

After some research I find out that df take into account currently open filed, even after their deletion.

[root@server httpd]# lsof | grep "/var/log/httpd"
httpd.wor 30576 root 19w REG 8,33 6854529 48 /var/log/httpd/internetfr-error_log-20150403 (deleted)
# [troncated]

Reloading Apache HTTPd resolved the situation, as it closed deleted file descriptors.

[root@server httpd]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdc1 40G 34G 3.5G 91% /var/log/httpd

Leave a Reply

Your email address will not be published. Required fields are marked *