Inodes & Links
Inode structure, stat output, hard links vs symlinks, inode exhaustion diagnosis, and df -i.
Overview
Every file and directory in a Linux filesystem is represented by an inode, a data structure stored in the filesystem's inode table. Understanding inodes is critical for diagnosing a range of subtle production issues, from 'disk full' errors when the disk has free space, to files that persist on disk after deletion.
What an Inode Contains
An inode stores all of a file's metadata except its name.
- File type: regular file, directory, symlink, device, socket or FIFO.
- Permissions: the read, write and execute bits for the owner, the group and everyone else.
- Owner: the UID and GID.
- Size: the file size in bytes.
- Three timestamps: atime (last access), mtime (last data modification) and ctime (last inode or metadata change).
- Link count: the number of directory entries pointing to this inode.
- Block pointers: direct, indirect and double-indirect pointers to the data blocks. The Inode Structure section below works out how much data each kind can reach.
Key concepts
- Inode
- Hard link
- Symbolic link
- Inode exhaustion
- Link count
- ctime vs mtime
Interview questions
- Your server reports "No space left on device" but df -h shows 40% free. What do you do?
- What is the difference between a hard link and a symbolic link? Give practical examples.
Sign up free to read the full topic
More Linux topics
Start free on Cariara · Coding problems · System design studio