seegongsik
Saved words
Operating systems

The File System: The Tree-Shaped Illusion Over a Flat Disk

Last time, drivers let us talk even to a device like the disk. But open up the disk and there are no files and no folders inside. Just numbered cells stretching on and on. In this flat sea of cells, how do we ever find one photo of ours?

01

The Disk's Bare Face: Just Numbered Cells

On screen we see files as icons, and we open a folder to find more folders inside. But the disk itself has none of that. The disk is really one giant locker of identical cells laid out flat in order: cell 0, cell 1, cell 2, and so on. Each cell is called a block. A block holds a chunk of data, but the disk itself has no idea which cell belongs to which file, or what its name is. Just a number and some data. That is all.

DISK · raw blocks
just numbers and data. no names, no folders.

Tap a cell to drop data in. Cells have only numbers, no names and no folders. This is the disk's bare face.

You can feel it now, right? Cells are told apart only by number, and their contents have no link to one another. A big file will not fit in a single cell, and empty cells are scattered all around. So one file has to be split across several cells, and then the question is how to gather those scattered pieces back together later. That is the first homework the operating system has to solve.

02

A File: A Name and a Map That Bind Scattered Blocks

The fix is surprisingly simple. The operating system keeps a little note: "the file named photo.jpg sits in cells 3, 7, and 12, in this order." That note is the map. Give it a name and the operating system unrolls the map, walks to the scattered cells in order, and gathers the pieces. So a file is really the sum of two things. One is the data pieces scattered across cells, the other is the map that binds them under a name. What we double-click is that map, and the disk simply reads the cells the map points to.

tap the name to follow the map
0
1
2
3 ▬
4
5
6
7 ▬
8
9
10
11

Tap the name and the map gathers the scattered cells (3, 7, 12) in order into one file. Watch scattered blocks become a whole file.

A single map bound the scattered cells into one file. Thanks to it, we can call a file by name without knowing any cell numbers. But what if there are not one or two files but thousands? Then thousands of name-notes pile up and it gets overwhelming again. We need a way to organize all these names. Enter the star of the next step: the folder.

03

A Folder: Another File That Holds Files

"Folder" sounds like something totally different from a file, but here is the secret: a folder is just another file too. What is special is only its contents. An ordinary file holds a photo or some text, but a folder-file holds "the list of name-notes inside it." So opening a folder means reading that list to see which names live there. You can also put a folder inside a folder. That makes a branching tree shape. Start at the root on top, ride the branches down, and you reach the file you want.

▾ root /
▸ photos/
▸ docs/
tap a folder to open it

Tap a folder to open it and see the files and subfolders inside. Follow the branches from the root down to the file you want.

As you can see, over what was a flat sea of cells there now stands a neat tree that branches up and down. Because a folder is just another file, the operating system built this organizing structure with nothing but the same idea of a file, without inventing a new gadget. But one curious question remains. When we delete a file we made this way, does its data really vanish from the disk at once? In the next step we lift the lid on that secret a little.

04

What Does Deleting Mean? The Map Goes, the Data Stays

Intuitively, deleting a file feels like its data is wiped clean off the disk. But the operating system usually does not do that. Emptying every data cell one by one takes a long time. So to finish fast, it erases only the name and the map, and leaves the data inside the cells as it was. Instead it just marks those cells as "now empty, free to reuse." Once the map is gone, the path to that data is cut, so to our eyes the file looks gone. Yet the contents inside the cells are still sitting right there.

draft.txt ▸ 4,8
4 ▬
8 ▬

Tap a file and delete it. The name and map fade (the path is cut) but the data in the cells stays. Only when a new file overwrites those cells does it truly disappear.

That is why a recovery tool can sometimes bring a deleted file back. If it can find the map again, it can re-stitch the cells that were still sitting in place. The other way around, once a new file overwrites those cells, the original data is gone for good. In the end, the heart of deleting was not erasing data but erasing the map that leads to it. By now you can see that files, folders, and deletion all stand on one single idea: maps and names.

05

The Tree-Shaped Illusion Laid Over a Flat Disk

Let us step back and see the whole. The disk's true form was flat, numbered cells. Over them the operating system worked three pieces of magic. First, with a name and a map it bound scattered cells into a single file. Second, with another file that holds files it made folders and raised a tree. Third, when deleting, it erased the map rather than the data. Thanks to these three, we can handle files comfortably with just names and folders, never knowing a single cell number our whole life.

tap 1 to start

Tap the three panels in order. From flat blocks, to a file bound by a name, to a folder tree. See at a glance how the illusion is built up.

Just as virtual memory showed us more memory than truly exists, the file system is an illusion that shows flat cells as a well-ordered tree. The truth is simple, and the convenience is something the operating system laid on top. But if many people share this tidy tree on one computer, should anyone be allowed to open and delete someone else's files? In the next lesson we begin the story of permissions: who may read, write, and run what, and how that order is kept.

In one lineThe disk's bare face is flat, numbered cells called blocks. On top of them the operating system lays a name and a map, binding scattered blocks into a single file, and uses another file that holds files to build a folder, a tree. Even deleting a file usually just erases the map and leaves the data sitting in place. The tidy files and folders we see are a well-built illusion the operating system paints over a flat disk.
Operating systems
Was this helpful? Support seegongsik