Frequently Asked Question
What is an inode and why does it matter?
An inode (index node) is the on-disk data structure that represents one file. It
stores everything about the file except its name and its contents: type, permissions,
owner, group, size, timestamps, link count, and pointers to the disk blocks that
hold the data. Every file on a filesystem has exactly one inode, identified by a
number you can see with ls -i or stat. The filename you use is only a label in a
directory entry, a (name, inode) pair, that points at the inode.
This indirection is what makes hard links possible (two names, same inode), why mv
within a filesystem is instant (just rewrite directory entries), and why a filesystem
can run out of inodes even when there is free space (each one is preallocated when
the filesystem is created, df -i shows the count). Inodes are also why a deleted
file with open file descriptors keeps existing: the link count drops to zero but the
kernel will not free the inode until the last descriptor closes.