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”: 没有那个文件或目录 du: 无法访问 “proc/15403/task/14464/fd/625”: 没有那个文件或目录 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 /]# 看到,占据的磁盘空间所有的加起来也不到30G,可是df -h下来,确实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. 以及leolein朋友的回复: 谢谢,就是这个原因。 我因为磁盘快满了就删除了一些过期的文件,可能应用程序还在使用这些文件句柄,所以导致了我说的问题。 我把所有的应用程序都停止后,du和df的结果就大致相同了 (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.