https://unix.stackexchange.com/questions/13828/df-says-i-have-20g-more-disk-space-used-than-du-why
That's because
du and df measure different things.man du says:du - estimate file space usage (...) Summarize disk usage of each FILE, recursively for directories.
and
man df:df - report file system disk space usage
File system has inode tables, journals etc. which are not summarized by
du. It isn't only Linux-specific, but rather UNIX-specific (or even UNIX-filesystem-specific). Because UNIX's processes uses files to everything (I'm simplifying) i.e. writing to log files, there could be also open file descriptorproblem in this case causing different du and df outputs.例如 inode Table 也會佔空間
The inode table (as well as a few very much smaller things) is included in the used space. It looks like you have about 18GB of inodes. That's around 6% of the space, which is in the expected ballpark for ext2/ext3/ext4 (filesystems that don't have an inode table are likely to have larger directory entries if nothing else). You can find the precise size used for inodes by running
tune2fs -l /dev/mapper/VolGroup00-LogVol00, e.g. here are the relevant lines for one of my 20GB ext3 filesystems:Inode count: 2622368
Inode size: 128
That partition has 2622368×128 B ≈ 320 MB of inodes.
Additional note: the way you've invoked
du, you'll see spaced used by every file even on remote mounts and other non-directly-disked-backed filesystems. Run du -x / to see just what's stored on the root filesystem.
可以用 tune2fs -l /dev/mapper/VolGroup00-LogVol00 看 inode Table 大小
可以用 du -x / 看沒有 mount 之前的大小 (排除 mount 的部分)
可以用 du -x / 看沒有 mount 之前的大小 (排除 mount 的部分)
如何看 mount point 底下原本的東西
https://community.spiceworks.com/topic/1111816-finding-what-data-is-under-an-nfs-mount-point
Mount something at /mnt/nfs
Listing the contents of /mnt/nfs this time confirms the contents of the mounted iso file, not the test files:
Mount the root fs using "--bind" to have it appear under a new mount point:
Now, cd'ing to /new-root/mnt/nfs, you are not in the mountpoint directory of the ISO filesystem
Confirm by listing the contents of /new-root/mnt/nfs and you will see the contents of /mnt/nfs from before its use a mountpoint.
還有一種可能
https://www.ndchost.com/wiki/troubleshooting/df-and-du-show-different-usage
There are times when the du and df commands can show different disk usage stats. The usual reason for this is that a running process still has a file that was removed open. This causes df to still report that space as used. The solution to this issue is to reload or restart that service so that it closes that file handle.
lsof is a tool that can be used to find processes holding onto files. If you do not have lsof installed, you will need to install it using your package manager. Examples of how to do this are below.
# Debian and Ubuntu apt-get install lsof # CentOS, RHEL, and Fedora yum install lsof
Next we want to use lsof to find the process
lsof | grep deleted
If you get any output changes are it looks something like this.
httpd 32617 nobody 106w REG 9,4 1835222944 688166 /var/log/apache/awstats_log (deleted)
In this case, the process httpd is whats holding onto an 18GB file. You can either kill that process, or issue a restart using init.d or systemctl
# systemctl systems systemctl restart httpd # Older init.d systems service httpd restart # Even older systems /etc/init.d/httpd restart
If the process doesn't have an init script you will need to restart it another way, or as a last resort kill the process. The second column output from lsof is the process id.
kill -9 32617
Now when running df again you should now see df reporting correctly.