Payments are experiencing issues due to temporary restrictions in Russia. If your payment does not go through, please submit a support request.Our support team is available 24/7 — we are always here to help with hosting and server issues.We are now accepting requests for dedicated server rental and colocation services in our data center.Reminder: we recommend enabling backups for additional data protection.A new VPS/VDS lineup with NVMe storage and improved performance is now available.Maintenance work on some servers has been completed. All services are operating normally.
Article3 min readViews1

File Deleted, But Space Not Freed: Diagnostics with lsof

How to find deleted files still held open by processes and gather data to safely free space without accidentally stopping the service.

Extracted drive connected to a computer via cable
In this article

A large log file was deleted, but almost no free space appeared. This is possible in Linux: the file name has already disappeared from the directory, but the process continues to keep it open. Until the kernel closes the last link to such an object, the blocks occupied by it may remain allocated.

Confirm the initial situation

This instruction applies to Linux with the lsof utility installed. Standard user permissions may limit visibility of other processes. If you administer the server, run the check with permissions allowed for your role; otherwise, delegate the task to the responsible specialist.

df -h /var

Record the file system and available space. The path /var is provided as an example: you need the specific volume where the deleted file was located. Without this binding, it is easy to mistake a temporary file belonging to someone else for the cause of the site partition filling up.

Find nameless open files

lsof includes filtering by the number of hard links. A value less than one allows you to find open files that have been deleted from the directory tree:

lsof -nP +L1

The -nP parameters disable the conversion of network addresses and ports into names. The output must include the process, its identifier, the descriptor, the device, and the size. If the list is empty, this may indicate the absence of such objects, but it could also mean insufficient permissions or visibility in the current process space.

Do not simply sum every line

One object may sometimes appear for multiple processes or descriptors. Simply summing all lines will overestimate the volume of space to be freed. Match the device and inode, and verify that the object belongs to the correct file system.

The deletion label itself is not a malfunction. Applications can legitimately create temporary files and remove their names while leaving open file descriptors. What matters is the size, the duration of retention, and the correlation with the observed growth in used space.

The next action depends on the application

For example, a web server may continue writing to an old log file after an incorrect rotation. In this case, check the standard log reopening mechanism. For a database, the cause and permissible actions will differ. There is no universal command that safely closes any found file.

Do not terminate the process simply because it appears at the top of the list. It may be handling current requests or transactions. Do not zero out file descriptors via utility paths: such interference can disrupt application operation and destroy data. Pass the found identifier, size, and observation time to the service owner.

Result verification

After the standard action selected by the administrator, repeat lsof -nP +L1 and measure the free space on the same partition. The disappearance of the specific held object along with an increase in free space confirms the hypothesis much better than the mere fact of restarting the service.

If the space has not changed, return to other causes: snapshots, file system metadata, or new records created during the check. Record the result even if the outcome is negative. This allows the next specialist to continue the diagnosis rather than repeating random deletions and restarts.

Discussion 0

Share your experience and ask questions. Comments without links appear after editorial review.

No comments yet. Start the discussion.