What Is an Inode in Linux

Running out of disk space normally means that a filesystem has no free bytes left. Sometimes, however, a command fails with “No space left on device” while df -h
still shows available space. One possible cause is inode exhaustion: the filesystem can store more data, but it has no free metadata records for new files.

To understand why this happens, and why filenames and file contents are stored separately, you need to know what an inode is. This guide explains what an inode stores, how it relates to filenames and hard links, and how to check inode usage.

What an Inode Is

An inode (short for “index node”) is a data structure that a Unix-style filesystem uses to store metadata about a file or directory. Each file has an inode number that identifies it within that filesystem. The same number can appear on another filesystem, so an inode number is not unique across the entire system.

The inode holds almost everything the system needs to know about the file, except for its name and, in the usual case, the data itself. It records:

  • The file type, such as a regular file, directory, or symbolic link
  • The permissions and owner and group IDs
  • The file size and allocated blocks
  • The access, data modification, and status change timestamps
  • The hard-link count, which is the number of directory entries pointing to the file
  • The block map or extents that locate the file’s data

The exact on-disk format depends on the filesystem, but these fields are the ones you see through tools such as ls and stat.

Filenames Are Separate from Inodes

The detail that surprises many users is that the filename is not stored in the inode. A directory contains entries that map names to inode numbers. When you open report.txt, the system looks up that name in the directory, finds the inode number, reads the inode, and locates the file’s data.

This separation is what makes hard links possible. A hard link is another directory entry that points to the same inode. Both names are equal, and removing one name only decreases the inode’s link count. The filesystem releases the file’s storage after the last link is removed and no process still has the file open.

For a practical comparison of the two link types, see hard links vs symbolic links
.

Viewing Inode Numbers

To see the inode number of a file, use the -i option with ls:

Terminal

ls -i report.txt

output

1310720 report.txt

The first column, 1310720, is the inode number. To list inode numbers for everything in a directory, run ls -li, which adds the inode number as the leftmost column of the long listing.

To display the metadata associated with the inode, use the stat
command:

Terminal

stat report.txt

output

 File: report.txt
Size: 482 Blocks: 8 IO Block: 4096 regular file
Device: 8,1 Inode: 1310720 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ linuxize) Gid: ( 1000/ linuxize)
Access: 2026-01-01 14:02:11.000000000 +0100
Modify: 2026-01-01 13:55:40.000000000 +0100
Change: 2026-01-01 13:55:40.000000000 +0100
Birth: 2026-01-01 13:55:40.000000000 +0100

The Inode field shows the inode number, and Links shows the hard-link count. Change is the status change time, commonly called ctime. It changes when inode metadata such as permissions, ownership, or the link count changes. It is not the file creation time. The separate Birth field shows creation time when the filesystem supports it.

The filename appears at the top because you passed it to stat; it is not part of the inode.

How Filesystems Allocate Inodes

Inode allocation depends on the filesystem. Ext2, ext3, and ext4 create inode tables when the filesystem is formatted. This gives the filesystem a fixed inode density, so a workload that creates millions of small files can use every inode before it uses every data block.

You cannot change the inode density of an existing ext4 filesystem in place. Growing the filesystem can add block groups and more inodes, but if the filesystem cannot be expanded, the practical options are to remove unneeded files, move the workload, or recreate the filesystem with a higher inode count.

XFS and Btrfs allocate inodes dynamically from available filesystem space instead of creating one fixed inode table at format time. They can still reject new files when the filesystem runs out of usable data or metadata space, but they do not have the same fixed inode-count limit as ext4.

Checking Inode Usage

To see how many inodes the filesystem containing /var has and how many are free, pass the path to df with the -i option:

Terminal

df -i /var

output

Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sdb1 655360 655360 0 100% /var

The IUse% column is the one to watch. Here, inode usage on /var is at 100 percent even though the byte-based df -h /var might still report free space. The filesystem cannot create another file until an inode becomes available.

A large cache, session directory, mail queue, or temporary directory is a common source of inode exhaustion. GNU du can count inodes instead of bytes. The following command stays on the /var filesystem, checks two directory levels, and displays the largest totals at the bottom:

Terminal

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

Repeat the command on the directory with the highest count and increase the depth if needed. For other counting methods, see the guide on counting files in a directory
.

Warning

Do not remove files only because a directory has a high inode count. First identify which application owns the files and use its cleanup or retention policy when one is available.

After cleanup, run df -i /var again to confirm that free inodes are available.

Conclusion

An inode connects a file’s metadata to its stored data while the directory keeps the filename separately. When a filesystem reports “No space left on device” despite having free bytes, check the affected path with df -i before deciding what to remove.

Scroll to Top