Inode Internals
Also known as: inode structure, filesystem inode, inode internals
An inode is the on-disk data structure that stores a file's metadata and pointers to its data blocks, but not its name or contents. The filesystem uses inodes to map a file to the actual storage blocks it occupies.
- An inode stores file metadata and block pointers, but not the filename or the file's contents.
- Filenames live in directory entries that map to an inode number; hard links share one inode.
- A file's data blocks are freed only when the inode's link count reaches zero.
What an inode stores
An inode (index node) holds everything a filesystem knows about a file except its name and its bytes: size, owner and group IDs, permission bits, timestamps, link count, and the pointers that locate the file's data on disk. Directory entries map a human-readable filename to an inode number; the inode number is the file's true identity within a volume.
Because the name lives in the directory and the metadata lives in the inode, a single inode can have multiple names. These are hard links, and the inode's link count tracks how many directory entries point to it. The file's blocks are freed only when that count drops to zero.
How inodes map files to blocks
An inode points to data through a mix of direct block pointers (which reference data blocks straight away) and indirect pointers (which reference blocks that themselves hold more pointers, allowing single, double, and triple indirection for large files). Modern filesystems like ext4 and APFS use extents or extent-like records to describe long runs of contiguous blocks more efficiently than per-block pointers.
During cleanup, deleting a file removes the directory entry and decrements the inode link count; when it reaches zero, the inode and its data blocks are returned to the free pool. A storage cleaner like Cleanor works above this layer by identifying large files and duplicate photos, but the actual space is reclaimed when these inode-to-block mappings are released.