Course contentsShow
← Linux
Lesson 275 of 1,8193. The Filesystem Hierarchy and POSIX StandardsFree lesson

Inodes and Metadata Storage

Explain how the kernel maps a file's inode number to its physical location on the storage medium.

In this lesson, you will learn how the Linux kernel uses the inode number as a map to navigate the physical storage medium and locate your file data.

The Inode as a Map

While a filename is just a label for humans, the kernel relies entirely on the inode number. Think of an inode as a specialized index card for a single file. Every filesystem is pre-divided into blocks (small chunks of disk space). When you create a file, the kernel assigns it an inode and records the metadata—such as permissions, timestamps, and owner—along with a list of pointers.

From Number to Bits

When you request a file, the kernel doesn't search for a name; it looks up the inode number in the filesystem's inode table. This table is a reserved area on the storage device that acts like a reference book. Each entry in this table contains block pointers.

These pointers act as a roadmap:

  1. Direct Pointers: Point directly to the specific data blocks where the file content is physically stored.
  2. Indirect Pointers: If a file is large, a single inode cannot hold all the locations. It points to a block that contains more pointers, effectively creating a tree structure to map out larger files.

You can observe this link between a filename and its inode number using the ls -i command:

$ ls -li document.txt
123456 -rw-r--r-- 1 user user 1024 Jan 01 10:00 document.txt

In this output, 123456 is the inode number. When the kernel needs to read document.txt, it jumps to the inode table entry 123456, retrieves the list of disk blocks associated with that entry, and commands the disk controller to fetch the data from those exact physical locations.

The file's name is actually stored in a separate directory file that simply links the human-readable string to the inode number. This is why you can have multiple names (hard links) pointing to the same inode: the data and metadata are stored once, while multiple directory entries point to the same map.

Key Takeaway: The inode is a metadata structure that holds the physical block addresses of a file, allowing the kernel to translate an abstract file request into a precise physical location on your disk.