Sobes.tech
Senior

What happened to a file that was deleted but its space on disk was not freed? How to check and fix?

sobes.tech AI

Answer from AI

If a file has been deleted but the disk space has not been freed, it is most likely that the file is still open by some process. In Unix-like systems, deleting a file removes its link in the filesystem, but if a process holds a descriptor to that file, the data remains on the disk until the descriptor is closed.

To check this:

  1. Use the command lsof | grep deleted — it will show open deleted files and the processes holding them.
  2. Find the process that is holding the file and restart or terminate it.

Example:

lsof | grep deleted

After closing the descriptor, the disk space will be freed automatically.

If you are using Windows, you can use tools like Process Explorer to find processes holding deleted files.

Also, check whether any hidden mount points are mounted or if files are being used in cache.

What happened to a file that was deleted but its… - sobes.tech