Du, df, and Linuxdudf in Linux
During Linux O & M, it is often found that the values of du and df are different, and sometimes they are very different.
In specific circumstances, df may see that the disk is full, but du determines that the disk space is large.
The file system allocates some disk blocks to record some of its own data, such as I nodes, disk distribution charts, indirect blocks, and super blocks. This Data is invisible to most user-level programs, usually referred to as Meta Data.
Df: run the command to view the disk block distribution graph of the file system to obtain the total number of blocks and the remaining number. Reflect the actual usage of the system disk.
Du: User State program. Only partial statistics of the file system are collected, regardless of MetaData.
So df> = du
If the difference between df and du values is very large, it indicates that some programs may specify the file output to the deleted file.
For example, when the log file is deleted during the running process, the program will continue to output to the fileHandler pointed to by the original log without terminating. Even if a new file with the same name is created, it is still written to the original file according to the original fileHandler. In df's view, the disk growth still exists, but du's view shows that the file has been deleted. After Long-term operation, df will see that the disk usage is much higher than du.
In this case, the process can be terminated, and the deleted file fileHandler will be recycled and deleted.
If you do not know the process ID, you can use lsof to query
# Lsof | grep delete
Original article: du and df-Zero-degree Space in Linux