Skip to content
Log In Sign Up info@muvcloud.com

The Short Answer

Every file on ext4, XFS, and most other Linux file systems has one inode, identified by a number that is unique within that file system. A directory is a list that maps names to inode numbers. When you open a file, the kernel looks up the name in the directory, finds the inode number, reads the inode, and from there finds the data blocks.

What an Inode Stores

Stored in the inodeNot stored
File type and permissionsThe file name
Owner and groupThe directory path
Size and timestampsThe data itself
Number of hard links
Location of the data blocks

Very small files and symbolic link targets can be stored inside the inode on some file systems, but for ordinary files the data lives in separate blocks.

See Inode Numbers with ls and stat

ls -i /etc/hostname
stat /etc/hostname

ls -i prints the inode number before the name. stat shows the full record: size, blocks, the inode number, the link count, permissions, owner, and the access, modify, and change times. More ls options are in the ls command.

Because the name is separate from the inode, one inode can have several names:

ln report.txt report-copy.txt
ls -li report.txt report-copy.txt

Both lines show the same inode number and a link count of 2. They are not a copy: a change through one name is visible through the other. The data is released only when the last name is removed and no program holds the file open. A symbolic link is different: it has its own inode and stores a path. See how to create a symlink in Linux.

Check Inode Use with df -i

df -i

The columns show the total inodes, the used and available ones, and IUse%, the share in use. A file system that has used all its inodes cannot create a new file, even when df -h still shows gigabytes of space. The result is the message described in no space left on device.

Find Directories with Many Files

Millions of small files, such as session files, cache entries, or queued mail, are the usual cause. Count entries in each directory below a path:

for d in /var/*; do echo "$(sudo find "$d" -xdev | wc -l) $d"; done | sort -n | tail

Repeat inside the directory with the highest count until you reach the one that fills up. Then fix the cause, for example an application that never cleans its cache or a cron job that writes a file every minute. Delete files through the application's own cleanup where it has one, and never delete files in database or package manager directories by hand. To find large files instead of many files, see how to find large files in Linux.

ext4 and XFS Handle Inodes Differently

  • ext4: the inodes are created with the file system, at a fixed ratio of bytes per inode. The ratio cannot be changed later; growing the file system adds inodes only at the same ratio. For a volume meant for many small files, ask for more inodes at creation with the -i (bytes per inode) or -N (number of inodes) option of mkfs.ext4.
  • XFS: inodes are allocated as needed, up to a maximum share of the space (the maxpct setting of mkfs.xfs), so running out is much less common.

The other differences between the two are in ext4 vs XFS.

Deleted Files That Keep Their Inode

If you remove a file that a running program still has open, the name disappears but the inode and its space stay in use until the program closes it. sudo lsof +L1 (from the lsof package) lists such files; restarting the service named there releases them.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations