Sysadmin

No space left on device inode: df -i and du –inodes

No space left on device inode: df -i and du –inodes

No space left on device inode in 60 seconds

# 1. The mount that actually matters, it is not always /
findmnt -T /var

# 2. Blocks and inodes: both need checking
df -h /var
df -i /var

# 3. What consumes inodes, staying on a single filesystem
sudo du --inodes -x -d 2 /var 2>/dev/null | sort -n | tail -15

# 4. How many files sit in the mail queue
sudo find /var/spool/postfix/maildrop -type f | wc -l

# 5. Targeted cleanup: PHP sessions older than 24 hours
sudo find /var/lib/php/sessions -type f -mmin +1440 -delete

One message stuck in the Postfix queue costs one more inode. Neither weighs on the gigabytes, and that is why the problem stays invisible until something stops working: an upload returning 500, a cron that does not write its lock, a package that will not install. df -h keeps showing free space and the diagnosis stalls right there, because you are looking at the wrong metric.

Below is the sequence to confirm the suspicion in two commands, isolate the responsible directory, clean up without bringing the server I/O to its knees, and set an alert that fires before the incident.

Reference versions: GNU coreutils 9.x series (df, du --inodes), e2fsprogs 1.47.x (tune2fs, mkfs.ext4), util-linux (findmnt), Monitoring Plugins 2.3.x (check_disk) · documentation consulted in December 2026

Prerequisites

  • Root or sudo access on the system generating the error.
  • GNU coreutils with du --inodes support: check with du --help, the entry must appear. On BusyBox and minimal systems the option is often missing.
  • e2fsprogs installed if the filesystem is ext2, ext3 or ext4: it provides tune2fs and dumpe2fs.
  • A margin of time. If the service is already failing, cleanup frees inodes immediately, while block space only comes back when the still-open handles are closed.

The symptom: df says free space, the system says disk full

No space left on device is the user-facing translation of the POSIX errno ENOSPC, number 28. The kernel returns it in two different situations: there are no more free data blocks, or there are no more free inodes. The application receives the same message, the log prints the same line, the cause is the opposite. The df man page says this implicitly but clearly: without the -i flag the command only reports blocks (df(1)).

In practice the sysadmin runs df -h /path, sees Use% at 40% and convinces himself the problem is elsewhere. Documented cases show exactly this scenario: ext4 with blocks at 40-45% and the creation of a trivial file failing systematically (Linuxize). df is not lying, it is answering the question it was asked.

First of all you should identify the correct filesystem, because the error may refer to a secondary mount: a separate /var, a data volume, a container overlay.

findmnt -T /var
# a typical output:
# TARGET SOURCE    FSTYPE OPTIONS
# /var   /dev/sda1 ext4   rw,relatime

With that data in hand the check becomes targeted. If the failing path is inside a container, the filesystem to look at is the one of the host that holds the layer, not the container root.

What inodes are and why they run out

The inode, index node, is the structure that describes a file: owner, group, permissions, timestamps, size, link count and pointers to data blocks. It does not contain the file name, that lives in the directory. Every regular file, every directory, every symlink consumes exactly one inode, and the available total is a finite resource for each filesystem (kernel docs ext4).

On ext4 the inode table is allocated statically during mkfs, block group by block group. The superblock records the total number of inodes and how many are free, and those numbers never change again for the whole life of the filesystem. mke2fs creates by default one inode per 16 KiB of space, so a 100 GB volume is born with roughly 6.5 million inodes: an enormous number as long as files are documents and archives, ridiculous if the application writes a 300-byte file for every visit.

That is where the trap sits. An environment with millions of tiny files exhausts the inode table well before the blocks. The filesystem refuses new creations even with tens of GB free, and it does so with the same error as a full disk.

Verifying with df -i

The check is short. First blocks, then inodes, on the same mount.

df -h /var
df -i /var

A typical output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        98G   39G   55G  42% /var

Filesystem      Inodes  IUsed   IFree IUse% Mounted on
/dev/sda1      6553600 6553600       0  100% /var

An IUse% close to the total with IFree exhausted closes the question: it is the inodes. If instead IUse% is low and Use% is high, the problem is blocks and this is not the right path.

On ext4 it is also worth reading the parameters the filesystem was created with, because they explain how much margin exists and how much will exist in the future.

sudo tune2fs -l /dev/sda1 | grep -i inode
# a typical output:
# Inode count:              6553600
# Free inodes:                    0
# Inodes per group:            8192
# Inode size:                  256

Watch out for one detail: tune2fs only works on ext2, ext3 and ext4. On an XFS volume it answers with a magic number error and the diagnosis has to be done with xfs_info; on btrfs the reference is btrfs filesystem usage.

Command What it answers When to use it
findmnt -T /path filesystem and device behind a path before any other check
df -h /path blocks used and free to rule out the classic full disk
df -i /path total, used, free inodes, IUse% when block space is available
du --inodes -x -d 2 inodes consumed per directory to locate the culprit
tune2fs -l /dev/sdX inode count and size at mkfs to understand the real margin on ext4
find … -delete controlled batch removal to clean millions of files

Finding the directory with millions of files

Once exhaustion is confirmed, you need the concentration point. du with the --inodes option counts inodes instead of blocks, and the GNU coreutils manual documents it explicitly (GNU coreutils).

sudo du --inodes -x -d 2 /var 2>/dev/null | sort -n | tail -15

The -x flag prevents descending into other filesystems, -d 2 limits depth, sort -n orders numerically and tail shows the heaviest directories by file count. From there you descend one level at a time, changing the path and leaving -d 1.

On a filesystem with millions of entries du still walks the whole tree, and it does so by reading metadata: it can take minutes and generate I/O. In production you should lower its priority.

sudo nice -n 19 ionice -c3 du --inodes -x -d 1 /var/lib 2>/dev/null | sort -n | tail

If the server is already under stress, it is better to start from known paths instead of scanning everything: /var/lib/php/sessions, /var/spool/postfix, /var/tmp, the application cache directories. Read also: Zabbix Agent 2: Installation, Configuration, and Plugins to keep these paths under measurement over time.

The usual suspects: PHP sessions, mail queues, caches

PHP sessions are the textbook case. The default files handler writes one file per session in the directory indicated by session.save_path, and the PHP manual notes that on some systems it is better to choose a filesystem designed for many small files (php.net). There is also a curious note: setting a depth level N of 3 or higher in the save_path can waste inodes and space for the tree structure it creates.

sudo find /var/lib/php/sessions -type f | wc -l
sudo find /var/lib/php/sessions -type f -mmin +1440 -delete

The second command deletes only files older than 24 hours, which is the window in which a session is still alive with default settings.

Mail queues are the other great classic. Postfix keeps queued messages as separate files under the queue_directory, by default /var/spool/postfix, and maildrop collects messages waiting for local delivery (postqueue(1)). A persistent delivery error or outbound abuse fills that directory in a few hours.

sudo find /var/spool/postfix/maildrop -type f | wc -l
sudo postqueue -p | tail -5

If the number is six digits, the problem is not cleanup but the upstream cause: a relay that refuses, an expired password, an application sending mail in a loop. Deleting the queue without removing the cause recreates it in a day.

The third group is application caches and temporary directories: failed uploads, jobs in error, print spools, framework caches. They are rarely documented, they are almost always the directory growing the most in file count and not in GB.

Deleting many files without blocking the server

rm -rf on a directory with millions of entries is a bad idea. The command works, but the kernel has to update one inode at a time, the shell stays silent for minutes and I/O saturates the disk the whole time. Operational guides recommend find with -delete or xargs rm, so deletion proceeds in controlled batches (Linuxize).

# direct deletion, with final count
sudo find /var/lib/php/sessions -type f -mmin +1440 -print -delete | wc -l

# batch alternative, useful when writers are still active
sudo find /var/spool/postfix/maildrop -type f -mmin +2880 -print0 | sudo xargs -0 -n 500 rm -f

The effect on inodes is immediate: a new df -i shows IFree growing without needing to unmount anything. To find those files you use lsof +L1.

sudo lsof +L1 | head -20

Restarting the service that holds the file open is often the only way to recover the blocks. Inodes, on the other hand, are already back.

Can you add inodes? ext4 versus XFS

The short answer is no, not on ext4. The number of inodes is fixed at mkfs and there is no command that increases it: the inode table is allocated statically and the superblock keeps the total count. The only path is to rebuild the filesystem with a different density and restore the data, as vendor guides document (Alibaba Cloud).

# ONLY after a verified backup and with the filesystem unmounted
sudo mkfs.ext4 -i 4096 /dev/sdb1

The -i option sets the bytes-per-inode: a lower value produces more inodes for the same capacity. Going too low has a cost, because each inode takes up space and removes blocks from data. Before reaching this point, a verified sample backup is not a detail: Read also: Backup 3-2-1-1-0: Rule Explained with Real Example.

XFS behaves differently. It allocates inodes dynamically, uses 64-bit numbers and accepts parameters like size, perblock and maxpct in mkfs.xfs, with sparse allocation that reduces chunks when free space is fragmented (mkfs.xfs(8)). It is not a magic wand, but it makes it far less likely that inodes become the bottleneck before blocks.

Characteristic ext4 XFS
Inode allocation static, at mkfs dynamic
Adding inodes to an existing filesystem no, needs reformatting handled through allocation
Density parameter -i (bytes-per-inode) -i size, perblock, maxpct
Reading parameters tune2fs -l xfs_info
Use case volumes with many small files, well sized large volumes, unpredictable growth

The choice is made at build time, not during the incident. Whoever prepares a new volume for sessions, caches or spools should size the inodes on the expected load: Read also: Proxmox VE 9 Sizing: Hardware Requirements for Nodes if the volume is born on a VM.

Preventing with a monitoring check

An alert only on blocks does not protect you from this scenario. The check_disk plugin from the Monitoring Plugins suite supports dedicated inode thresholds: -W or --iwarning puts the check in WARNING when the percentage of free inodes drops below the threshold, -K or --icritical does the same in CRITICAL, and -P or --iperfdata includes inode usage in the performance data (check_disk).

/usr/lib/nagios/plugins/check_disk -w 10% -c 5% -W 10% -K 5% -P /var

The two pairs of thresholds are independent: -w and -c concern block space, -W and -K concern inodes. Setting -W to a meaningful threshold means being warned when a reduced share of inodes remains, that is with the time needed to understand which directory is growing. On filesystems where the file count is stable and low the threshold can be wider, on those hosting sessions or spools it is better to tighten it.

Alongside the alert, you need a periodic measurement: du --inodes on two or three critical directories, once a week, to see growth in file count. The GB chart will show nothing, the inode chart will.

Common Errors and Troubleshooting

Exact error or message Cause Solution
No space left on device with df -h showing free space inodes exhausted df -i on the correct mount, then du --inodes -x
No space left on device and df -i almost empty blocks exhausted or deleted files still open lsof +L1, restart the service holding the handle
df -i on / is normal but the error persists the path lives on another mount or a container overlay findmnt -T /path before any check
tune2fs: Bad magic number while trying to open non-ext filesystem (XFS, btrfs) xfs_info or btrfs filesystem usage
find: cannot delete … Directory not empty processes writing while you delete stop the writer or repeat the find
rm -rf seems stuck on a huge directory I/O and per-inode overhead switch to find -delete or xargs -n 500
du --inodes: unrecognized option coreutils too old or BusyBox update coreutils or use find -printf with counting

Frequently Asked Questions

Do I need to restart the service after deleting session files?

Not to free inodes, which become available as soon as the file is removed. The restart is needed when the process still holds the handle of an already deleted file: in that case the inode is free but the blocks stay occupied and df -h does not drop. A reload of the web service or the session manager closes those handles and returns the byte space too.

Why does df -h show free space but I cannot create even an empty file?

Because creating a file requires two resources: one block for the updated directory and one inode for the new file. If the inode table is full the operation fails before touching the blocks, and the kernel returns ENOSPC, the same error as a full disk. The correct check is df -i on the mount that contains the path, not df -h.

Can I increase inodes without reformatting the filesystem?

On ext2, ext3 and ext4, no. The inode table is allocated at mkfs and the total is recorded in the superblock: there is no command to add more. The only path is to rebuild the filesystem with a lower bytes-per-inode value and restore the data from a verified backup. On XFS allocation is dynamic and the problem shows up less often.

Is du --inodes slower than regular du?

It requires the same tree traversal, so the time depends on the number of entries and not on the option. On a directory with millions of files it can take minutes and generate metadata I/O. In production you should run it with nice and ionice, or limit depth with -d and start from suspicious directories instead of the root.

Do exhausted inodes also block Docker containers?

Yes, indirectly. Container layers and volumes live on a host filesystem, often overlay2 or a dedicated volume: if that filesystem exhausts inodes, containers can no longer write logs, temporary files or application data. The check has to be done on the host with df -i, not inside the container, because the internal mount will show different numbers.

Conclusions with Operational Takeaways

Three things to take away. First: when you read No space left on device the first thing to do is not look for big files, it is to run df -i on the mount that contains the path, after identifying it with findmnt -T. Second: du --inodes -x is the tool that turns a suspicion into a precise directory, and it should be used with low priority because it reads metadata across the whole tree. Third: on ext4 inodes cannot be added, so sizing happens at build time and monitoring is configured with check_disk -W and -K, not just with block thresholds.

The rest is hygiene: a retention window on PHP sessions, a periodic check of the Postfix queue, a weekly measurement of the file count in the directories that grow. None of these activities is spectacular, all of them prevent the incident. Read also: Ubuntu Server Upgrade: do-release-upgrade and Best Practices if the fleet is still on an old release and the filesystem needs to be rethought together with the system.

Sources

Updated: December 2026

Share this article:

Written by

Rosario Giordano

Rosario Giordano is a system administrator and IT consultant specializing in cybersecurity and cloud, with over 20 years of experience managing enterprise Linux infrastructures. His areas of expertise include SSH hardening, Kubernetes platforms, PostgreSQL databases, VMware/ Proxmox virtualization, and compliance with NIS2 and ISO 27001 security frameworks