When your server displays “No space left on device”, but it shows plenty of free disk space, the problem is often inode exhaustion, not storage. This technical blog guide explores inodes, explains why you might run out of them, and provides a detailed, actionable solution to fix and prevent the issue.
What Are Inodes and Why They Matter?
In Linux filesystems like ext4 and ext3, every file or directory uses a structure called an inode. Each inode holds metadata, permissions, timestamps, ownership, pointers to data blocks. When you run out of inodes, you can’t create new files, even if disk space remains (“No space left on device”).
Diagnosing Inode Exhaustion
You can easily check inode usage with following command:
df -i
If the IUse% column shows 100%, you’re out of inodes. Now in order to find heavy directories, you can use following command:
du --inodes -d 3 / | sort -n | tail -20
or:
for dir in /*; do echo "$dir: $(find "$dir" | wc -l)"; done
This reveals directories with excessive file counts.
Why Does Inodes Fill Up?
- Many small files (logs, cache, sessions) use inodes quickly.
- Applications (WordPress, Magento) generate heaps of cache & sessions.
- Email storage (one file per email in mail servers).
- Old backups stored locally; each file consumes an inode.
- Misconfigured cron jobs/scripts producing files continuously.
Step-by-Step Fix to Inodes Limitation Issue
1. Clean Cache and Temporary Files
You can find the following paths for concern applications to clear cache and temporary files.
- WordPress: Clear wp-content/cache.
- Magento: Empty var/cache/, var/sessions/.
- PHP sessions often stored under /var/lib/php/sessions.
rm -rf /var/www/*/wp-content/cache/* find /var/lib/php/sessions -type f -mtime +1 -delete
Alternatively, use CMS commands like wp cache flush.
2. Rotate or Remove Logs
Log files accumulate quickly. You can use the following command:
find /var/log -type f -name "*.log" -mtime +7 -delete
or configure logrotate with compression for long-term management.
3. Remove Local Backups
Backups stored on your server can consume thousands of inodes. Offload them to cloud storage and delete local copies.
4. Audit and Fix File-Generating Processes
Use inode counts to locate problem directories. Then check cron jobs, plugins, or scripts creating excessive files. Disable or fix the offending processes.
5. When to Recreate the Filesystem
If inodes consistently fill up despite cleanup, you may need to rebuild the filesystem with higher inode allowance:
- Backup all data.
- Unmount the partition.
- You can run the following command:
mkfs.ext4 -N <num_inodes> /dev/sdX
- Restore data.
This step is advanced: only perform during scheduled maintenance windows.
Tips to Prevent Inode Issues
- Automate cache, session, and log cleanup with cron.
- Offload backups to remote/cloud storage.
- Use external caching/CDNs to reduce file generation.
- Regularly monitor inodes with df -i.
- Choose file systems with dynamic inode allocation (like XFS or btrfs) for heavy small-file workloads.
Conclusion
Running out of inodes stops your server from creating new files leading to unpredictable downtime, failed uploads, and application errors. Solving it involves identifying where small files are piling up, cleaning them out, and automating the cleanup process. For persistent issues, you may need to reformat the filesystem or shift to a dynamic inode system.
Ultimately, maintaining inode health is just as critical as managing disk storage. Clear chatter files, limit unnecessary logs, offload backups, and monitor regularly to keep your server running smoothly.
Frequently Asked Questions
1. How are disk space and inode usage different?Disk space measures byte capacity; inodes measure how many files and directories you can create. It’s possible to have free disk space but zero inodes left.
2. Can inode limits be increased without formatting?
Not on ext2/3/4. You must back up, recreate the filesystem with a higher inode count, and restore your data.
3. Why not switch filesystems?
Filesystems like XFS, btrfs, and ZFS allocate inodes dynamically and avoid fixed limits—but migrating requires planning and possible data downtime.
4. Does a server reboot free inodes?
Reboots might release inodes associated with deleted but open files, but won’t solve high file counts. Clean up remains the reliable fix.
Salwa Mujtaba
Salwa Mujtaba is a Technical Content Writer at Cloudways. With a strong background in Computer Science and prior experience as a team lead in Cloudways Operations, she brings a deep understanding of the Cloudways Platform to her writing. Salwa creates content that simplifies complex concepts, making them accessible and engaging for readers. When she's not writing, you can find her enjoying good music, reading a book, or spending quality time with her family.