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 inode | Not stored |
|---|---|
| File type and permissions | The file name |
| Owner and group | The directory path |
| Size and timestamps | The 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/hostnamels -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.
Hard Links Share an Inode
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.txtBoth 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 -iThe 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 | tailRepeat 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 ofmkfs.ext4. - XFS: inodes are allocated as needed, up to a maximum share of the space (the
maxpctsetting ofmkfs.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.
More Guides
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.

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