Why deleting a file in Linux may not free disk space immediately
On Linux, running the rm command only removes a file's directory entry, not its underlying data blocks. If a running process still holds an open file descriptor to that file, the operating system retains the data on disk until that reference is released. This means disk space is not reclaimed even after a file appears deleted, which can catch administrators off guard during storage emergencies. The lsof utility can identify which process is keeping a deleted file alive by listing open file descriptors marked as deleted. To reclaim space without restarting a service, administrators can truncate the file descriptor to zero bytes via the /proc filesystem or gracefully reload the offending process.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in