File System Implementation Details

A file system helps the computer keep track of files. It controls how data is stored and retrieved.

What is a File System?

A file system is part of the operating system. It organizes data on a storage device like:

Think of a file system like a bookshelf. It keeps books (files) in order, with labels and shelves (folders).

Main Jobs of a File System

File Control Block (FCB)

Every file has a small data structure called a File Control Block or FCB.

The FCB stores information like:

Storage Blocks

The disk is divided into small pieces called blocks.

Files are saved in these blocks. The file system keeps track of which blocks belong to which file.

Daily Life Analogy

Imagine storing socks in drawers. Each drawer holds a few socks. You write on paper which drawer has which socks. That paper is like the file table.

How Files are Stored

There are several ways files can be stored on disk:

1. Contiguous Allocation

The file is stored in one big block of space.

Pros: Fast access.

Cons: Hard to find big enough empty space.

2. Linked Allocation

Each part of the file is stored separately. Each block points to the next.

Pros: Easy to grow files.

Cons: Slower to read all parts.

3. Indexed Allocation

The file has an index block. The index lists all the block locations.

Pros: Easy to access blocks directly.

Cons: Slightly more complex.

Directory Structure

Files are placed in directories (folders). This creates a tree-like structure.

Example:

  /
  ├── home
  │   ├── alice
  │   │   └── homework.txt
  │   └── bob
  │       └── notes.doc
  

Mounting a File System

A file system must be "mounted" before use.

Mounting connects the storage device to the OS's file structure.

File Access Methods

Free Space Management

The OS must also track empty blocks.

It may use:

File System Types

There are many file system formats. Each has its own features.

Daily Life Analogy: Office Cabinet

Think of a file system like a filing cabinet in an office. Each drawer (folder) holds files. You have a sheet that shows what file is in which drawer and what page it starts on. That sheet is like the directory table.

Summary

📘 Key Terms

🛠️ Try It Yourself

Open a command terminal:

In Linux:

df -h

Shows your mounted file systems.

In Windows:

diskpart

View and manage disks and volumes.

Great work! 🎉