Everyday Guidebooks
Cover of The Linux Guide Book to Disk Space Troubleshooting

Cybersecurity & IT

The Linux Guide Book to Disk Space Troubleshooting

Inspect Filesystem Usage, Find Large and Deleted-Open Files, and Diagnose Inode Exhaustion

by Todd Michael

Available now

A full filesystem can interrupt services, block updates, and leave you wondering where the space went. This linux guide book gives you a practical investigation method that starts with reliable measurements and ends with an informed decision—not a rushed deletion.

Using worked command examples, you’ll learn to inspect mounted filesystems, compare reported usage with directory totals, locate unusually large files, and investigate files that have been deleted but remain open in running processes. You’ll also identify inode exhaustion, a less obvious problem that can prevent new files from being created even when storage space appears available.

Each stage explains what the output means, what can make it misleading, and what to check before taking action. Practice scenarios bring the steps together so you can build confidence in a lab and apply the same disciplined approach on real Linux systems. Ideal for developing administrators, IT certification candidates, and anyone responsible for keeping Linux machines running.

Contents
  1. 1. Start With the Symptom
  2. 2. Understand Filesystems and Mount Points
  3. 3. Measure Space With df
  4. 4. Map Directory Usage With du
  5. From a Filesystem to a Directory Tree
  6. What du Counts
  7. Start With a Shallow Map
  8. Choose Units for the Question
  9. Keep Mount Boundaries in View
  10. Read Errors as Evidence
  11. Expect a Moving Target
  12. A Worked Directory Map
  13. Assessment Checkpoint
  14. 5. Find Large Files and Directories
  15. Start With the Right Search Area
  16. Sort Directory Totals
  17. Find Files Above a Size Threshold
  18. Keep Filesystem Boundaries in View
  19. Rank Individual Files by Allocated Usage
  20. Handle Names as Data, Not Shell Syntax
  21. Practice: Narrow a Busy Directory
  22. Checkpoint: What Have You Actually Found?
  23. 6. Assess Findings Before Cleanup
  24. 7. Investigate Growing Logs
  25. 8. Examine Temporary Files, Caches, and Archives
  26. 9. Find Deleted Files Still Held Open
  27. 10. Resolve the df and du Mismatch
  28. 11. Diagnose Inode Exhaustion
  29. 12. Handle Common Measurement Complications
  30. 13. Practice Four Troubleshooting Cases
  31. 14. Build Your Investigation Runbook
  32. Other Books by Todd Michael

Read a sample: 1. Start With the Symptom

A disk-space investigation often begins with an application that cannot do something ordinary. A backup fails. A service cannot write a log entry. A user receives an error while saving a document. The immediate suspicion may be that the disk is full, but the symptom is narrower than the diagnosis: a write or related operation failed.

That distinction matters because several conditions can produce similar complaints. A filesystem may have little available space, but a process can also fail because it lacks permission, has reached a quota, is writing to a read-only filesystem, or cannot create another file because the filesystem has exhausted its inodes. An application may even report a general “disk full” message when the underlying error is more specific.

The goal of this chapter is not to fix every possible failure. It is to establish a disciplined starting point: capture the evidence, identify the affected path, perform a few appropriate checks, and resist changing files until you understand what the findings mean. You will also create a small practice area for the examples in this book.

Suppose a developer reports, “The server is out of space.” Before running a cleanup command, ask what happened.

A useful initial report might read:

> At 10:18, a backup job on backup01 failed while writing under /srv/backups. The job log reported No space left on device. Earlier runs completed successfully.

This report does not prove which resource is exhausted, but it gives you a path, an error, a time, and an affected operation. Those details are enough to begin testing possibilities.

Record as much of the following as you can obtain without interrupting the service:

- The host or environment where the failure occurred. - The time of the failure, including the time zone when relevant. - The application, command, or service that failed. - The affected file or directory path. - The exact error text and, if available, the relevant log entry. - Whether the failure affects one user, one application, or several unrelated operations. - Whether the problem is ongoing or occurred only during a particular job.

Preserve the original message rather than replacing it with your interpretation. “The backup failed with No space left on device” is evidence. “The backup disk is full” is a hypothesis until you check it.

The path deserves special attention. Linux presents files and directories in one tree, but different parts of that tree can reside on different filesystems. A report about /srv/backups calls for investigation of the filesystem containing that path, not an assumption based on the usage of / or the size of a physical disk.

If the application reports a filename that no longer exists, record it anyway. Its parent directory may still identify the relevant location. If the application writes to a temporary directory before moving a completed file, the failure may have occurred in the temporary location rather than the final destination. Use the logs or application configuration to establish where the failed operation actually took place.

Error messages narrow the investigation, but they do not always provide a complete explanation.

No space left on device is an important clue. It can indicate that the filesystem cannot allocate the space required for the operation. It can also appear when inode availability is exhausted: a filesystem may have room for file contents but be unable to create another file. Filesystem-specific allocation limits and other constraints can complicate the picture, so check the relevant resource rather than assuming the first explanation.

Disk quota exceeded points toward a quota or similar limit. A filesystem can show available capacity overall while a particular user, group, or project cannot allocate more. The next step is to identify the account and quota arrangement involved, not to conclude that the whole filesystem is full.

Permission denied calls for a different line of inquiry. The process may lack permission on the file or on one of the directories in the path. Access-control settings or security policy may also matter. Freeing disk space does not resolve an authorization problem.

Read-only file system means the attempted operation reached a filesystem that is not accepting writes in its current state. That condition deserves investigation on its own. Do not simply force a remount or alter settings as a first response; understand why the filesystem is read-only and follow the system’s operational procedures.

An application’s own message may be less precise than these examples. If a user interface says “Unable to save,” inspect the application’s logs and context before assigning a cause. Also remember that a failed write can result from an application-specific limit or an unavailable remote service. The investigation should follow the error, not just the title of this book.

Once you have an affected path, start with a targeted filesystem check. For an existing directory such as /srv/backups, run:

bash df -h /srv/backups

The -h option requests human-readable sizes. By supplying the path, you ask df to report on the filesystem containing it. A shortened example might look like this:

text Filesystem Size Used Avail Use% Mounted on /dev/sdb1 200G 194G 6.0G 98% /srv

Read this as a snapshot: the filesystem mounted at /srv has relatively little space reported as available compared with its total size. It is a reason to investigate, not a complete explanation of the backup failure. A backup requiring more available capacity than remains could fail even before the display reaches 100%; conversely,…

More Cybersecurity & IT

Cover of The White Hat Bible, Volume 1The White Hat Bible, Volume 1Available nowCover of The White Hat Bible, Volume 2The White Hat Bible, Volume 2Available nowCover of The White Hat Bible, Volume 3The White Hat Bible, Volume 3Available nowCover of The White Hat Bible, Volume 4The White Hat Bible, Volume 4Available nowThe White Hat Bible, Volume 5Available nowCover of The White Hat Pocket GuideThe White Hat Pocket GuideAvailable now

About Todd Michael

Todd Michael is an American author and the founder of ToddMichael.tv. He writes practical, plain-English books on money, health, preparedness, technology, games, humor and more.

About the author Todd Michael · Todd Michael’s author site

Part of the ToddMichael.tv network.