2,去/根目錄check,du -sh * [root@localhost ~]# cd / [root@localhost /]# du -sh * 7.8M bin 6.9M boot 131M data 196K dev 111M etc 178M home 131M lib 23M lib64 119M logs 16K lost+found 8.0K media 0 misc 8.0K mnt 0 net 0 nohup.out 3.8G opt 15M pcre-8.33 2.1M pcre-8.33.zip du: 無法訪問 “proc/11575/task/11575/fd/1565”: 沒有那個(gè)文件或目錄 du: 無法訪問 “proc/15403/task/14464/fd/625”: 沒有那個(gè)文件或目錄 0 proc 1.4G product 153M repo 143M root 37M sbin 8.0K selinux 363M soft 8.0K srv 0 sys 20K temp 100K tftpboot 2.1G tmp 8.6G usr 184M var 30M varnish-3.0.3 56M zabbix-2.0.8 [root@localhost /]# 看到,占據(jù)的磁盤空間所有的加起來也不到30G,可是df -h下來,確實(shí)100%呢?差異在哪里?
3,baidu,google資料,找到 http://www.chinaunix.net/old_jh/6/465673.html 里面有這么2段話: (1): When you open a file, you get a pointer. Subsequent writes to this file references this file pointer. The write call does not check to see if the file is there or not. It just writes to the specified number of characters starting at a predetermined location. Regardless of whether the file exist or not, disk blocks are used by the write operation.
The df command reports the number of disk blocks used while du goes through the file structure and and reports the number of blocks used by each directory. As far as du is concerned, the file used by the process does not exist, so it does not report blocks used by this phantom file. But df keeps track of disk blocks used, and it reports the blocks used by this phantom file. 以及l(fā)eolein朋友的回復(fù): 謝謝,就是這個(gè)原因。 我因?yàn)榇疟P快滿了就刪除了一些過期的文件,可能應(yīng)用程序還在使用這些文件句柄,所以導(dǎo)致了我說的問題。 我把所有的應(yīng)用程序都停止后,du和df的結(jié)果就大致相同了 (2): This section gives the technical explanation of why du and df sometimes report different totals of disk space usage.
When a program that is running in the background writes to a file while the process is running, the file to which this process is writing is deleted. Running df and du shows a discrepancy in the amount of disk space usage. The df command shows a higher value.