A service reports that it cannot create a file, yet the filesystem still has free gigabytes. Check its inode statistics alongside byte capacity. A workload producing many small files can reach a different limit from a workload writing a few large files.
This guide uses GNU Coreutils and Python 3 on Debian or Ubuntu. The disposable lab creates 1,000 empty files under your home directory. It demonstrates accounting and scoped cleanup. It deliberately leaves the filesystem far from exhaustion.
1. Identify the affected filesystem
Use the directory where the failed write occurred. The example checks a log directory.
|
|
Read the available byte and inode counts together with the application’s exact error. Filesystem implementations account for inodes differently, so interpret the values using the filesystem type. Quotas, read-only mounts, permissions, and metadata capacity can also block writes.
| Observation | Next investigation |
|---|---|
| Bytes available, inode availability exhausted | Locate file-heavy trees and inspect their retention policy. |
| Bytes exhausted | Locate space usage and check deleted-but-open files. |
| Both appear available | Inspect quotas, mount state, permissions, and the exact application error. |
| Statistics unavailable or unusual | Use the filesystem’s own administration tools and documentation. |
An inode identifies a filesystem object and stores its metadata. Directory entries name objects. Multiple hard links can refer to one inode, so a count of names is not always a count of distinct objects.
For the related case where deletion fails to release bytes, see the deleted-but-open-file guide.
2. Find where the inode usage is concentrated
Start with a bounded directory on the affected filesystem. GNU du can count inode usage instead of storage blocks.
|
|
Select a high-count child from the output and repeat at that path. The -x option keeps the walk within one filesystem. Keep permission errors visible. A deep scan on a busy tree can take time and consume I/O.
Review the owner and purpose of the concentrated data. Common candidates include application caches, spool directories, generated thumbnails, and abandoned job outputs. A large count can be legitimate. The recovery decision depends on the application and retention contract.
3. Practice counting in a disposable lab
Check that your home filesystem has enough byte and inode headroom first. Then create a unique directory and 1,000 empty files.
|
|
Expect the final command to count 1,000 regular files. GNU du’s inode total also includes the directories it visits. Even empty files require metadata, and directories themselves can consume storage. Actual allocated bytes vary by filesystem.
The lab does not need a measurable change in the host-wide percentage to succeed. Its useful observations are the scoped file count and the inode count of that tree.
4. Delete only the files created by this lab
Keep using the same shell so lab_dir still refers to the unique directory. The cleanup checks that the child directory contains exactly the expected names and only regular files before unlinking them.
|
|
On a production tree, use the application’s documented retention or cleanup operation. Coordinate with the owner and preserve necessary evidence before deleting records. Stop or pause a runaway producer through its supported controls when it would immediately refill the space.
Deleted data requires an appropriate backup for recovery. Preview the proposed cleanup scope and establish a recovery point before applying a retention change.
5. Verify recovery and prevent recurrence
After the approved cleanup, rerun both df commands against the affected path. Confirm that the application can create and use its required data, then watch its file growth over a representative period.
Record the filesystem, object count, producer, retention change, and application result. Monitor both byte capacity and file capacity where the filesystem exposes meaningful inode statistics. Choose thresholds that leave time to investigate and run cleanup.
Filesystem growth or migration can be appropriate when the object count is legitimate. Plan that work using filesystem-specific documentation, a tested backup, and the workload’s expected file count. Deleting arbitrary directories or reformatting a volume is not a diagnostic step.