What’s an inode and what’s inside of one? (Linux First Principles)

Connor Brereton
3 min readApr 7, 2020
inode architecture — Source

Before I get into a bunch of technical details I want to touch on one thing that is instrumental to know before diving deep: in Linux, everything is a file — you heard that right — everything is a file.

But what about sockets you might say? What about a hard link? These are all files. Simple as that.

The important thing to know is that while everything is a file there are different types of files! This is crucial to know as we build upon our knowledge.

Now that you know that everything is a file it’s important to know that Linux uses something called the VFS — virtual file system. In this VFS there are four main abstractions that we use:

  1. Files (regular, special, etc.)
  2. Directory entries (aka dentry)
  3. Inodes
  4. Mount points

This diagram below will help you see the big picture of what a file system in a UNIX system is really composed of at a “big picture” level:

You see the hard disk itself is the actual hardware cylinder. That’s what memory is in computers. Each partition of the hard disk is a section of the actual piece of hardware for the cylinder memory unit. These partitions are accessed through the boot block.

Each of these partitions has what’s called a cylinder group which is the next level of abstraction away from physical memory and is a grouping of things that make up the inode list table which is our reference to the inodes themselves.

How are inodes created though?

Inodes get created through the superblock struct (a literal struct data structure in C) as the files are accessed. This same logic applies to special files as well. They get created on an “as needed” basis because it makes the most sense to create them on the fly rather than create a static amount and then when you run out of them have to create more (this would cause delays in the UX for the OS).

Why are inodes used?

--

--