← Lessons

quiz vs the machine

Silver1060

System Design

File System Basics

How an operating system maps named files onto raw blocks of a disk.

4 min read · intro · beat Silver to climb

What a file system does

A file system turns a flat sea of fixed size disk blocks into named, hierarchical files. Without it you would address storage by raw block number. The file system gives you names, directories, sizes, and permissions instead.

The core pieces

  • Inode holds metadata for one file: size, owner, timestamps, and pointers to its data blocks.
  • Directory is just a special file that maps names to inode numbers.
  • Data blocks store the actual file contents in fixed size chunks.
  • Superblock records global layout such as block size and free space.

Reading a file

To open a path the system walks each directory component, looking up the next name to find its inode, until it reaches the target. Then it follows the inode pointers to read data blocks. Larger files use indirect blocks, which are blocks that point to more blocks, so a small inode can address a big file.

Why blocks matter

Disks read and write in whole blocks, so a one byte file still consumes a block. Choosing a block size trades internal waste for fewer pointers and more efficient large reads.

Key idea

A file system layers names, inodes, and directories over fixed size blocks so that programs can work with paths and metadata instead of raw disk addresses.

Check yourself

Answer to earn rating on the learn ladder.

1. What does an inode primarily store?

2. How is a directory represented?