df -h shows gigabytes free. You restart the service, same error. You check disk usage again, still plenty of room. This is one of the more confusing Linux failure modes, and it almost always comes down to inodes.
What Inodes Are and Why They Run Out
Step 1: Check Inode Usage with df -i
BASH
df -iTEXT
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 6553600 6553600 0 100% /
tmpfs 505765 1 505764 1% /dev/shmIUse% column. If any mounted filesystem shows 100% (or very close), that is your problem. The IFree column showing 0 confirms it — no inodes left, no new files possible, regardless of free bytes.
Compare this with regular disk usage:
BASH
df -hdf -h shows free space but df -i shows 100% usage, you have confirmed inode exhaustion.
Step 2: Find Which Directories Hold the Most Files
BASH
find / -xdev -type f | cut -d '/' -f 2,3,4 | sort | uniq -c | sort -rn | head -20find / -xdev -type f— find all regular files on the same filesystem (the-xdevflag prevents crossing into other mounted filesystems)cut -d '/' -f 2,3,4— extract the first three directory levels from each pathsort | uniq -c | sort -rn— count occurrences and sort by count, highest firsthead -20— show top 20 directories
/var/spool/exim/inputor/var/spool/postfix— mail queue buildup, often from spam or misconfigured mailing scripts/tmpor/var/tmp— session files, especially PHP sessions that never get cleaned/home/*/public_html/wp-content/cache— WordPress cache plugins generating per-page or per-query cache files/var/lib/php/sessions— PHP session storage on systems with long or no session garbage collection/home/*/mail— maildir accounts with tens of thousands of individual email files
BASH
ls -1 /var/spool/exim/input/ | wc -lStep 3: Clean Up Safely
BASH
exim -bpcexim -Mvh <message-id>), you can clear the queue. But first identify and stop whatever is generating the mail — a compromised contact form, a PHP script sending spam, a forwarding loop.
Session files: Old PHP session files in /tmp or /var/lib/php/sessions are generally safe to remove if they are older than your session lifetime. A common approach:
BASH
find /tmp -maxdepth 1 -name 'sess_*' -type f -mtime +2 -delete-mtime to match your application's session timeout. The -delete flag is irreversible — double-check the path and the -name pattern before running it.
Cache directories: WordPress cache plugins like WP Super Cache or LiteSpeed Cache can generate enormous numbers of small files. Clearing the cache through the plugin's admin panel is safest. If the site is down and you need to clear from CLI, remove the contents of the cache directory (not the directory itself).
Important: After cleanup, verify inode usage dropped:
BASH
df -iIUse% dropped significantly, the problem is resolved. If it barely moved, you have not found the real culprit yet — go back to the find command and look deeper.
Step 4: Prevent Recurrence
php.ini directives that control session cleanup: session.gc_probability, session.gc_divisor, and session.gc_maxlifetime. On some distributions, garbage collection is disabled in PHP-FPM and handled by a system cron job instead. If that cron job is missing or broken, sessions pile up forever. Check whether your setup relies on PHP's built-in GC or a system cron, and make sure whichever mechanism is in place actually runs.
Mail queue monitoring. A mail queue that grows without bound usually means something is sending mail faster than it can be delivered (or the messages are undeliverable). Monitoring queue size — even a simple cron that runs exim -bpc or mailq | tail -1 and alerts above a threshold — catches this before inodes run out.
Cache size limits. Most caching plugins and tools have configuration options to limit total cache size or file count. Use them. An unbounded cache on a filesystem with fixed inodes is a slow-motion failure.
Journald logs. On systemd-based systems, journald can accumulate significant numbers of journal files under /var/log/journal/. Setting SystemMaxUse in /etc/systemd/journald.conf caps this. For more detail on managing journald storage, see systemd Journal Filling /var on a WHM Server: Vacuum Once or Set SystemMaxUse?.
Shared hosting environments often enforce inode limits per account as a soft resource boundary. If you are on shared hosting and hitting inode limits, the approach is the same — find which directories have the most files and clean or restructure. The article Unlimited Shared Hosting Has an Inode Limit: Why It Breaks MDX Sites and News Portals covers that angle specifically, though the internal link is not in the approved list so check your provider's documentation for their specific limits.
Quick Reference: The Verification Sequence
df -h shows free space:
- Run
df -i— check if any filesystem is at or near 100% inode usage. - Run the
find | cut | sort | uniq -cpipeline to locate directories with the most files. - Identify what the files are before deleting anything.
- Clean up the files, then run
df -iagain to confirm inodes were freed. - Fix the root cause — session GC, mail queue, cache limits — so it does not recur.
df -i becomes the second thing you check after df -h, every time.