Rain WikiWindows · Linux · Android

Inodes and 'No space left on device'

Conceptext4 and similar file systems

An inode is the data structure a Unix-style file system uses to store information about a file, such as its owner, permissions, size and where its data lives. Each file uses one inode, and many file systems have a fixed number, so millions of tiny files can cause 'No space left on device' while df -h still shows free space.

1How to see it

df -i lists total, used and free inodes per file system. ls -i shows a file's inode number, and stat <file> shows its inode details.

2Typical causes

Session or cache directories of web applications, mail queues, unrotated small log files and build caches can create millions of files.

3Finding the directory

GNU du can count inodes: du --inodes -x / | sort -n | tail lists the directories with the most entries.

How to fix inode exhaustion

  1. Confirm: df -i (IUse% near 100%).
  2. Find the directory: sudo du --inodes -x --max-depth=3 / | sort -n | tail -20
  3. Check what creates the files before deleting anything.
  4. Remove old files of that application with its own tool, or with find, for example: find /path -type f -mtime +7 -delete after a dry run without -delete.

Cautions

  • Always run find without -delete first and read the list.
  • The inode count of ext4 is fixed when the file system is created.

Sources

  1. inode(7) man7.org
  2. df(1) man7.org
  3. du(1) man7.org
  4. find(1) man7.org

Last reviewed: