Skip to content
We areTOP 1%

What is an inode, and what information does it store?

MediumConceptFile Systems & Disk Scheduling
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

An inode (index node) is the structure that Unix and Linux file systems, such as ext4, use to describe a file. It stores the file's metadata and the locations of its data blocks, but not the file's name. Each inode is identified by a number, and the name lives in a directory, which maps names to inode numbers.

  • Metadata: file type, permissions, owner and group, size, timestamps (access, modify, change) and the link count (how many names point to it).
  • Block pointers: classic ext2/ext3 inodes have 12 direct pointers plus single, double and triple indirect pointers. With 4 KB blocks, the direct pointers cover 48 KB, and one indirect block adds 1,024 pointers, another 4 MB. ext4 uses extents (runs of consecutive blocks) instead.
  • Because names are stored separately, one file can have several names (hard links), and renaming a file within one file system only changes a directory entry.
  • ext4 creates its inodes when the file system is formatted, so millions of tiny files can exhaust the inodes while disk space is still free.

Example: ls -i notes.txt prints 1048602 notes.txt. To open /home/user/notes.txt, the kernel reads the directory /home/user, finds the entry notes.txt → 1048602, reads inode 1048602 to check permissions and get the block pointers, and only then reads the data blocks.

More in File Systems & Disk Scheduling

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account