In the daily operation and maintenance process, we often need to deal with disk space issues, when we receive alarms, the first time we will go to find those large files, generally such as centos, the large file may be
But sometimes, there is a situation where you can’t find the big files, and when you look for them by
du, the size of the statistics doesn’t correspond to the space occupied by
If the inode is not full by
df -i, then most likely, there is a large file is directly rm, but there are still processes open the file.
In this case, because the process did not exit, so the space occupied by the file will not be released; until the process exits, the disk space will not really be released.
Question 1: How do I find out which process opened the file?
On linux, since the process is still alive, it can be viewed by looking at all the fd’s opened by the process and if the file has been deleted, when viewed, it will show
The example is as follows.
Question 2: How can this be avoided?
Do not delete the file directly, but free up disk space by truncating the file.
One way to do this is to
In this way, the space can be released quickly.