I previously wrote a system to monitor the remaining space on the disk script, today it sent me to the police, so I log on to the server to view, the results found that DF and du looked out of the results are different, du looked out of the "actual use of space" is much smaller than the DF found in the use of space, which is why? Is there some space hidden?
Finally, the power of the internet to solve the "strange" event, and the whole record.
First, we use DF to view the space used:
From the known, the root partition has been used 5456700KB (contract 5.20GB).
We then use du to isolate the size of each directory under the root partition:
Excluding the two directories in the red box (because they are mounted), the total size of all directories is 3075332KB (contract 2.93GB), which is smaller than the DF detected by 2.27GB.
Why is there so much less space?
In fact, because we have deleted some of the process is writing to the file, although we have been deleted, but as long as the process is still there, the file will not be really deleted, just temporarily stored somewhere in the system, a bit like the Windows Recycle Bin.
To solve this problem, the simplest is to restart the server, but the production environment is generally not easy to restart, so we can be solved by other means.
Use the lsof command with the grep command to find out which ones have been deleted, but still occupy the system space "rogue".
The file in the red box is just a large file I deleted earlier, I'm trying to restart the program (node), I kill the process directly, because I did the auto-start, so I don't have to start it manually.
The space used has dropped to 3226324KB (contract 3.08GB) and is already close to the total space of DU statistics.
Next, I restarted the other deleted files one by one, and the size of DF was almost as large as the total space of DU statistics.
To this, it solved the DF and du looked out the results of different files, drove away the system of "rogue", to return to our space.
If the reader is still unable to solve the problem according to this law, your situation may not be the same as mine.
Solve the problem of different space used by DF and Du