Data center floor with multiple tall server racks receding into

Linux Inode Exhaustion: When Free Disk Space Isn’t Enough

Your server can show the error “No space left on device” even when df -h reports gigabytes of free space. That’s because Linux tracks both disk space and inodes, which store information about individual files. When your server runs out of inodes, it can’t create new files, even if plenty of disk space remains.

Many monitoring tools track disk space but overlook inode usage. This makes the error harder to diagnose. Basic Linux covers these kinds of confusing Linux issues in its guides.

Below, you’ll see why the error appears with free space, how the df -i command exposes the real count, and which directories fill first. Cleanup and alert steps close it out, so read on.

Why Does Linux Say No Space Left on Device When df Shows Free Space?

System administrator sitting at a desk in a dimly lit server room

As we were saying, Linux can show the error when the system runs out of inodes. Inodes store basic information about each file, including its owner, permissions, size, and data location. Every file and directory needs one inode, so the filesystem can reach its inode limit while storage space remains available.

This is why a large number of small files cause problems. A 1 KB session file and a 4 GB video each use one inode, regardless of their size. As a result, millions of small files exhaust the available inodes long before the disk fills up.

The problem is harder to fix on ext4 because you set the inode supply when you format. According to the Linux kernel documentation, ext4 allocates inode tables when you create the filesystem. You can’t simply increase the number later without rebuilding the filesystem. Once the supply runs out, you need to delete files to free up inodes.

Unfortunately, the error message doesn’t tell you which limit you’ve reached. Linux reports the same “no space” error when either disk blocks or inodes run out, so applications may report a full disk even when storage is available. You might first notice the problem when your web server stops accepting uploads or users can no longer log in. Meanwhile, df -h may still show plenty of free disk space.

The df -i Command Shows the Linux Inode Usage That df -h Hides

The df -i command shows how many inodes your Linux server has used and how many are still available. Unlike df -h, which reports disk space, it focuses on inode usage. The output includes four columns: Inodes, IUsed, IFree and IUse%.

Start with the IUse% column. A mount sitting at 100% there can’t accept a new file, lock file, or temp file, even with half the disk empty (Btrfs reports zeros in this column, which is normal).

After identifying the full filesystem, you need to find which directory contains the most files. The command du --inodes -x / | sort -n | tail helps locate directories with high inode usage. You can then investigate those directories using other essential Linux commands to find what is filling them.

When you read the output, watch for these warning signs:

  • IUse% above 90% on / or /var
  • IFree dropping by thousands between daily checks
  • A single directory containing hundreds of thousands of files
  • Plenty of free disk space but very few inodes remaining
  • Apps failing to create temporary files while existing files continue to grow

Of these, the clearest warning sign is having plenty of free disk space while the inode count is nearly exhausted. Since df -h doesn’t show inode usage, this problem can go unnoticed during regular disk checks. Treat any mount above 90% inode usage as urgent and find the directory responsible before applications start failing.

System administrator's hands carefully removing a hard drive

Common Culprits: Where Linux Inode Exhaustion Starts on a Busy Server

Now that you can find the full directory, the next question is what filled it. Linux inode exhaustion nearly always traces back to software that writes small files and never removes them. We’ve grouped the five places worth checking first under the headings that follow.

PHP Session Files That Nobody Garbage Collects

PHP stores visitor sessions as small files, often in /var/lib/php/sessions. On Debian and Ubuntu, a cron task handles session cleanup instead of PHP’s built-in cleanup process.

If that cron task stops working, old session files can build up and use thousands of inodes. That’s why this directory is worth checking when a server runs low on inodes.

Run ls -f | wc -l inside the session directory to count its files. Then check whether session.gc_maxlifetime matches how long user sessions should remain active.

WordPress Plugin Caches and Package Manager Leftovers

WordPress cache plugins create files for cached pages, sometimes storing separate copies for different device types. On busy online stores, these files can quickly build up and use thousands of inodes. Other software can add to the problem, as package managers also store large numbers of small files.

For example, old kernel headers in /usr/src and cached files from apt and Composer can take up many inodes. You can clear WordPress caches through the plugin settings rather than deleting folders manually. Then run apt autoremove to remove unused packages and composer clear-cache to clear Composer’s stored files.

Mail Queues, Cron Output and Rotated Log Fragments

Cron jobs that produce output may send an email after every run. If the server can’t deliver those messages, they can build up as individual files on disk. Check Postfix’s maildrop folder for this type of clutter.

Old log files can cause a similar problem. Without a maxage setting, logrotate may keep compressed logs indefinitely, using more inodes over time.

To prevent this buildup, add >/dev/null 2>&1 to cron lines that don’t need to send output. Then check your logrotate settings and set appropriate rotate and maxage values to limit how long old logs stay on the server.

Docker Overlay2 Layers and Abandoned Build Contexts

Docker stores image layers in /var/lib/docker/overlay2, with each layer containing many files. As you build and update images, old layers and build caches can accumulate thousands of files and use up available inodes.

Docker doesn’t remove this unused data automatically. Its pruning guide explains that you must manually remove unused images and build data. This is worth checking if you build images on the same VPS that runs your containers.

Run df -i /var/lib/docker to check inodes, and docker system df for reclaimable data. You can then use docker image prune and docker builder prune to remove unused images and build caches. Remember to check what a prune removes before you run it on a production host

Shared Hosting Accounts With a Per-Account Inode Cap

On shared hosting, providers often set a separate inode limit for each account, alongside the disk space limit. This keeps one customer’s files from using too many server resources and affecting other websites.

Because of this limit, your account can run out of inodes even when the server still has plenty of free space. Backups, emails, and WordPress cache files all use inodes, so they can quickly push your account towards its limit.

You can check your usage in the cPanel sidebar, usually under File Usage. Keep an eye on this figure each month and move old backups or mailboxes elsewhere if the count keeps rising. This helps prevent your account from reaching its inode cap.

Freeing Inodes Now and Preventing the Next Outage

With the usual suspects mapped out, cleanup becomes a targeted job rather than a guessing game. Deleting the right small files frees inodes straight away, so you won’t lose your Friday arvo to a rebuild.

Thinking about how to recover and stay recovered? These three steps cover both:

  1. Delete With Find: Running rm * in a directory with thousands of files can trigger an “Argument list too long” error. Use find /path -type f -mmin +1440 -delete to remove files older than a day. Replace -delete with -print first to review the files before removing them. However, never delete inside /var/lib/docker by hand. Clear the mail queue with postsuper, and check what a directory holds first
  2. Alert on IUse%: A simple cron script can email you when inode usage passes 85%. Add it to your existing disk space alerts and choose a threshold that gives you at least one working day to respond.
  3. Plan Inodes at Format Time: When preparing a new ext4 volume for millions of small files, set the bytes-per-inode ratio using mkfs.ext4 -i. You can’t change the ratio later, so calculate your needs before you format.

Clear the excess files first, then set up your alert on the same day. Without regular monitoring, the same directories can fill up again and cause another outage.

Long corridor between two rows of tall server racks in a data center

Check Inodes Before Your Next Disk Alert

Free disk space only tells half the story, because Linux also needs a free inode for every file it creates. Track Linux inode usage beside your disk percentage, and that baffling error loses its surprise.

Run df -i on your main servers to check the IUse% for each mount. Record these figures and add them to your regular monitoring checks so you can spot inode shortages before they affect your services.

Basic Linux shares practical guides for admins and developers who want to understand their systems. Talk to Basic Linux to suggest a topic or ask about an error that’s stumping you.

Leave a Reply

Your email address will not be published. Required fields are marked *