Infrastructure

Linux: diagnose inode exhaustion before deleting files

A production runbook for finding the source of small files, protecting queued data and restoring writes after inode exhaustion.

05 Dec 2026 linuxfilesystemobservabilityincidentrunbookrollbackproduction

A worker can no longer create files in its local queue, even though the volume still has gigabytes free. The error says “No space left on device”. Deleting large logs or extending the disk before identifying the exhausted resource may not restore service and can destroy useful evidence.

This runbook follows a Linux VM where a service writes small files under /var/spool/exporter. The path is fictional. Adapt the read-only commands to the host, permissions and service mount namespace. Recursive scans on a stressed volume can be expensive: limit their scope and monitor their impact.

Identify the affected filesystem

Record the UTC time, exact error, service, path and recent changes. Check the effect on in-flight work and agree with the service owner whether to pause new input. Do not delete files from a live queue simply to recover space.

findmnt -T /var/spool/exporter
df -hT /var/spool/exporter
df -i /var/spool/exporter

findmnt identifies the mount containing the path; df -hT shows space and filesystem type; df -i reports inode counters. If the service runs in a container or isolated mount namespace, run the checks in its context and compare the result with the host.

ObservationNext step
Inodes exhausted, blocks availableFind directories and producers creating large numbers of objects.
Blocks exhausted, inodes availableInspect large files and deleted files still held open.
Both have headroomInvestigate quotas, permissions, read-only mounts and the exact error.

An inode holds an object’s metadata; multiple hard-linked names can refer to the same inode. Counters and expansion options depend on the filesystem. Increasing disk size alone therefore does not guarantee more available inodes.

Locate the producer without deleting

Start with known service directories, temporary queues and recently changed retention settings. On GNU find, the following counts visible entries on the same filesystem, not unique inodes; it includes directories and may count multiple links to one inode.

sudo find /var/spool/exporter -xdev -printf '.' | wc -c
sudo find /var/spool/exporter -xdev -maxdepth 2 -type d -print
sudo find /var/spool/exporter -xdev -type f -mmin -60 -printf '.' | wc -c

Adjust the window and compare specific subdirectories one at a time. -xdev avoids crossing into other filesystems, but does not replace a mount review: a bind mount on the same filesystem can still appear in the walk. Missing permissions, read errors, concurrent creation and hidden mounts can make counts incomplete. Keep errors visible and avoid running several scans at once.

In this example, a temporary export queue has grown since the last deployment. Correlate its growth with worker logs, processing failures, configured retention and consumer health. Old files are not automatically disposable: they may be queued, open or required for recovery.

Contain the flow and release an approved batch

With the service owner, distinguish active, pending, completed and recoverable files. Check retention rules, backups and preservation requirements. Where possible, pause the producer or reduce its rate without disabling critical evidence collection; confirm the upstream queue can tolerate the pause.

Prefer the application’s documented purge or archive mechanism. Before deletion, have a bounded candidate list, file state and age reviewed; confirm the files are no longer needed and can be restored if necessary. Process a small batch, measure recovered inodes and reassess. Do not run a generic recursive deletion against a production queue. Removing the final name does not necessarily release an inode immediately while the file remains open.

Then fix the evidenced cause: a blocked consumer, repeated failures, disabled retention or a temporary-file leak. Limit a configuration change to one canary and document the prior version and recovery procedure.

Validate and decide

Repeat df -i and df -hT against the same path. Confirm inode headroom rises and remains stable for a workload-appropriate window, and that a representative file is created and processed through to its expected result. Check the queue for lost or duplicated work, and verify logs and alerting.

Decision: restore throughput gradually only when the consumer keeps up and inode headroom remains adequate. If exhaustion returns, stop the ramp and preserve fresh evidence. Restore the previous configuration if the fix harms service, but do not claim that deletion can be rolled back: recover data from a verified backup or escalate if it cannot be recovered.

References