Why Deleted Files Still Occupy Disk Space: How File System Inodes and Process References Work
This article explains why deleting a large file often fails to free disk space on servers with POSIX-like file systems. It covers the relationship between directory entries, inodes, and data blocks; why log files are the most common trigger; how to trace space usage through a systematic evidence chain; how to safely release file references held by processes; and how to prevent the problem from recurring with proper log rotation practices. Readers will learn a repeatable troubleshooting methodology rather than a single quick fix.
1. Deleted Successfully, But Space Usage Doesn’t Drop
On servers using POSIX-like file system semantics, administrators frequently encounter a puzzling situation: a large file has been deleted and no longer appears in its directory, yet the file system’s used space barely changes. If the file was a continuously growing log, space usage may even keep rising.
This usually does not mean the deletion failed. It happens because “the filename disappearing” and “the file content being reclaimed” occur at different stages of the file lifecycle.
Deletion first acts on the name in the directory. As long as the file is still referenced by a process, the operating system may keep its inode and data blocks alive so that ongoing reads and writes can complete normally. Only after all references are released—and the file system’s reclamation conditions are met—does the space become available again.
So when handling this problem, don’t just check whether the file exists in the directory. Ask three questions:
- Does the file still have other hard links?
- Is a process still holding a file descriptor or another valid reference to it?
- Could the observed space change be affected by how usage is measured or by the underlying storage mechanism?
2. Understanding Filenames, Inodes, and Data Blocks
2.1 A Filename Is an Entry Point, Not the File Content
A directory can be understood as a mapping between names and file objects. When a user accesses a file via a path, the system first looks up the directory entry, then locates the inode, and finally finds the file’s data.
This relationship can be expressed as:
Filename in the directory entry↓Inode↓Data blocks and file metadata
The inode records the file type, permissions, owner, size, link count, and the information needed to locate its data. Filenames are stored in directory entries, not as part of the file’s data blocks.
This design allows the same file object to have multiple names, and allows processes to keep using a file after its name has disappeared.
2.2 Hard Links Determine Whether the File Is Still Reachable
Multiple directory entries can point to the same inode; these entries form hard links to one another.
Deleting one of these names usually only decrements the link count. As long as other hard links remain, the file is still accessible through other paths, and its data will not be reclaimed just because one name was removed.
Therefore, “the original path no longer exists” does not prove the file has no remaining names. If hard links exist, first confirm whether they serve a legitimate business purpose instead of blindly deleting more entries.
Symbolic links are different: they store a target path and do not add a hard link to the target inode.
2.3 File Descriptors Let Processes Bypass the Original Path
After a process opens a file, it receives a file descriptor. Subsequent reads and writes go through the descriptor; the original filename is not looked up again.
The relationship can be simplified as:
File descriptor in the process↓Open file state in the kernel↓File object and its data
Deleting a directory entry does not automatically invalidate existing file descriptors.
So a file can simultaneously be in these states:
- Its original path no longer exists
- Its hard link count has dropped to zero
- A process still holds a valid file descriptor
- That process can still read from or write to the file
On ordinary local file systems, a file’s space becomes eligible for reclamation only when the file has no hard links and no valid references that require keeping it. Beyond regular file descriptors, other reference types such as memory mappings must also be considered—don’t mechanically limit the check to “are there any open descriptors?”
3. Why Log Files Trigger This Problem Most Often
Suppose a service opens a log file at startup and keeps writing through the same file descriptor. An administrator, trying to free up space, deletes the log file directly.
After the deletion, the service typically doesn’t notice that “the path is gone,” because its write target is not the path string but the file object it opened earlier.
This produces two seemingly contradictory yet entirely compatible results:
- The old log is no longer visible in the directory.
- The service keeps writing to the old file, and disk space continues to be consumed.
Even if the administrator creates a new log file with the same name in the original location, the service will not necessarily switch to it. The new file usually corresponds to a new inode, while the old file descriptor still points to the old object.
This shows that log cleanup cannot revolve around filenames alone; it must also coordinate with the process writing the log. A correct log switch requires the writer to close the old file and then open the new target file.
4. Locating Space Usage via an Evidence Chain
4.1 Confirm You Are Inspecting the Same File System
Before troubleshooting, record the file system containing the target path, its total capacity, used space, and available space. Also confirm you are observing the same mount point before and after deletion.
If directories contain nested mounts, or workloads run in isolated environments, the same path may mean different things. Looking only at path names makes it easy to conflate two different storage scopes.
At minimum, save the following information:
Target pathFile system / mount pointUsed space before and after deletionAvailable space before and after deletionSampling timestamps
Don’t judge whether space changed based solely on rounded integer output. Small releases can be hidden by display units and rounding.
4.2 Distinguish Directory-Level Stats from File System-Level Stats
Directory traversal statistics mainly count files currently reachable through directory entries. File system capacity statistics reflect the space allocated and available within that file system.
When a file has been deleted but is still referenced by a process, it no longer appears in normal directory traversal results, yet its data blocks still occupy file system space.
So if “the total size of files in the directory clearly dropped, but file system used space didn’t,” prioritize checking for files with no directory entries that are still referenced.
However, this discrepancy is not the only possible explanation. File system metadata, reserved space, snapshots, and shared data blocks can also cause the two statistics to diverge.
4.3 Inspect File Objects Held by Processes
Use the process file reference information provided by the system, or file-occupancy diagnostic tools with equivalent capabilities, to find files that have no directory links but are still held by processes.
Pay attention to the following details:
- The process ID and the service it belongs to
- The file descriptor number
- Whether the file is a regular file
- Whether the hard link count is zero
- Whether it carries a deleted marker
- Which file system it resides on
- File size and actual allocated space
- Whether it is still growing
Different diagnostic tools may label these fields differently; do not treat any displayed value as the file size by default. In particular, distinguish logical length, read/write offset, and actual allocated space.
The locating process can be expressed in pseudocode:
Iterate over visible processesRetrieve file references held by each processFilter for regular files on the target file systemCheck whether they have no directory linksRecord process, reference number, file identity, and space infoSample at intervals to determine whether usage keeps growing
If the diagnostic account lacks sufficient privileges, some process or file information may be invisible. “Nothing found” does not necessarily mean “nothing is being held.”
4.4 Avoid Double Counting When Aggregating
The same file may be opened multiple times by one process, or held jointly by multiple processes. Summing file sizes across every descriptor record will overestimate actual usage.
A more reliable approach is to deduplicate by file system identifier plus inode identifier, then estimate space usage.
Also, the logical length of a sparse file can be far larger than its actually allocated space. When estimating how much capacity can be freed, rely on allocated block counts rather than file length alone.
5. After Finding the Holding Process: How to Handle It Safely
5.1 Prefer Application-Supported Reopen Mechanisms
For log-writing processes, the ideal approach is usually to have the application close the old log and reopen the target path, rather than immediately terminating the whole service.
But first confirm the application actually supports this behavior, and follow its operating conventions. Reloading configuration does not necessarily reopen log files, and sending a control signal to a process does not guarantee a consistent reopen semantic.
After the operation, verify again: whether the old file reference is gone, whether the new log is being written, and whether space changed as expected.
5.2 If a Restart Is Unavoidable, Use a Controlled Process
If the application has no way to close or reopen files independently, a controlled restart can release the references—but evaluate the business impact first.
A sound process includes:
- Confirm the process identity and the service it belongs to, to avoid acting on the wrong target.
- Check for in-flight requests, background tasks, or pending writes.
- If necessary, drain traffic or pause task intake.
- Stop the process gracefully, allowing time for cleanup.
- Confirm the references have been released.
- Restart the service and verify its health status.
Forced termination should only be an emergency measure taken with a clear understanding of the risks. It can cause loss of buffered data, interrupted transactions, or increased recovery costs.
5.3 Don’t Treat Truncation as a Universal Fix
Truncating a file reduces its content, but for a file that is still being written, the risk depends on how the application writes.
If the application does not write in append mode, the old offset may persist after truncation, and subsequent writes may create holes, causing the file’s logical length to balloon again. Even with append-mode writes, truncation discards content outright and can race with concurrent writes.
Operating on a deleted file through a process-held reference is also a high-risk action. File descriptors can change, and the process state may shift between your check and your operation.
Therefore, truncation is only appropriate when the content is confirmed disposable, the target can be reliably located, the write behavior is well understood, and a recovery plan exists. It must not be used as a routine remedy for database files, transaction logs, or files of unknown business purpose.
6. References Released but Space Still Unchanged: What Else to Check
If you have confirmed the target file has no hard links and no valid references, but space still hasn’t recovered as expected, broaden the investigation.
6.1 Snapshots or Shared Data May Still Hold Underlying Blocks
On storage using copy-on-write or shared-block mechanisms, deleting a file from the current directory does not mean the underlying data has no other references. Objects such as snapshots may continue to hold those blocks.
In that case, inspect the relevant storage mechanism instead of repeatedly killing application processes.
6.2 File System Reclamation and Media Reclamation Are Different Things
The file system marking space as available and the underlying storage device actually reclaiming that capacity can be two separate stages. Background reclamation, transaction commits, or capacity reporting refreshes may introduce delays.
But this cannot serve as a blanket explanation. For usage that stays persistently unchanged, keep verifying the specific cause instead of waiting indefinitely.
6.3 Releases and New Writes May Happen Simultaneously
The old file’s space may have been released, but other workloads may have written a similar amount of data at the same time, making total used space appear unchanged.
So when verifying, combine time series and write activity rather than comparing just two total capacity readings.
7. Preventing Recurrence at the Source
Log management must account for both “file rotation” and “switching the write target.” Merely renaming a file, moving the old file, or deleting it does not guarantee the application stops using the old object.
Sound principles include:
- Clearly define who creates, writes, and rotates each log
- Prefer close-and-reopen flows that the application can cooperate with
- Set reasonable retention periods and capacity caps
- Confirm an old log is no longer being written before cleaning it up
- Set up capacity and growth-rate alerts for abnormal growth
- Periodically check for large files with no directory links that are still held by processes
- Include emergency response steps in your operations runbook
Ultimately, the disk space problem after file deletion should be judged along a complete evidence chain: whether the directory entry was removed, whether hard links dropped to zero, whether process references were released, whether the data blocks meet reclamation conditions, and whether other retention mechanisms still exist at the storage layer. Understanding this chain is what turns the surface observation “the file is gone” into a verifiable, actionable technical problem.
