Inode Exhaustion
Linux Linux
Severity: ModerateWhat Does This Error Mean?
Inode exhaustion happens when you run out of inodes even though there is still free disk space. An inode is a data structure Linux uses to represent each file — every file needs exactly one inode regardless of its size. If the inode table is full, you cannot create new files even if there is plenty of disk space available. This commonly happens when a directory accumulates millions of tiny files.
Affected Models
- Ubuntu
- Debian
- Fedora
- CentOS
- Arch Linux
- Linux Mint
- openSUSE
Common Causes
- A mail spool, log directory, or cache directory has accumulated millions of tiny files
- A build system, package manager, or application created too many small temporary files
- The file system was created with too few inodes for the actual number of files being stored
- Session files, PHP sessions, or application temporary files were never cleaned up
- A backup or sync tool created a very large number of small incremental files
How to Fix It
-
Confirm the problem is inodes, not disk space. Type: df -i — this shows inode usage. Look for any file system showing IUse% at or near 100%. Compare with: df -h to confirm disk space is actually available.
The df -i command is the key diagnostic here. It shows inode usage separately from disk block usage.
-
Find which directory has the most files. Type: find / -xdev -printf '%h ' | sort | uniq -c | sort -k 1 -n | tail -20 — this shows the directories with the most files.
This command can take several minutes to run. It identifies the directory causing the inode problem so you can target your cleanup.
-
Clean up mail spools if applicable. Check: ls /var/spool/mail/ and: ls /var/mail/ — if any users have massive mail spools, clear them with: sudo rm /var/mail/[username]
Undeliverable mail or spam collected by local mail services can create millions of queue files, exhausting inodes very quickly.
-
Clean up PHP or application session files. Check: ls /var/lib/php/sessions/ or wherever your app stores sessions — delete old sessions: sudo find /var/lib/php/sessions -type f -mtime +7 -delete (removes files older than 7 days).
Web applications that generate but never clean up session files are a classic cause of inode exhaustion on web servers.
-
Clean up temporary and cache directories. Check and clean: sudo find /tmp -type f -mtime +7 -delete and: sudo find /var/tmp -type f -mtime +30 -delete — adjust the day count as appropriate for your system.
Temporary files that accumulate over months add up to enormous numbers of inodes. Regular automated cleanup prevents this from recurring.
When to Call a Professional
If the file system was created with too few inodes and cannot be reformed without data loss, a professional can migrate data to a new file system with a higher inode ratio. This is a complex operation requiring careful planning.
Frequently Asked Questions
What is an inode?
An inode (index node) is a data structure on a Linux file system that stores all information about a file except its name and content. It records the file's owner, permissions, size, timestamps, and the disk block addresses where the file's data is stored. Every file and directory needs exactly one inode. The file system is created with a fixed number of inodes — once they are all used, no more files can be created.
Can I add more inodes without reformatting?
On ext2/ext3/ext4 file systems, the inode count is fixed at creation time and cannot be changed without reformatting. On newer file systems like Btrfs and XFS, inodes are allocated dynamically and this problem does not occur in the same way. The practical solution for ext4 inode exhaustion is to find and delete the large number of small files causing it, rather than reformatting.
How do I prevent inode exhaustion in the future?
Set up automated cleanup for high-file-count directories. For web servers: configure PHP session cleanup via session.gc_probability and session.gc_maxlifetime. For mail systems: ensure your mail transfer agent has proper queue cleanup configured. You can also create file systems with a lower bytes-per-inode ratio (more inodes per gigabyte) when you know the volume will store many small files.