Fundamentals 11 min read

Understanding Linux File Systems Through MINIX: A Visual Guide

This article explains the principles of Linux file systems using clear diagrams and the simple MINIX file system as a teaching example, covering hard‑drive basics, file and directory structures, inode layouts, formatting layout, and step‑by‑step file‑reading procedures.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Understanding Linux File Systems Through MINIX: A Visual Guide

1. Hard‑Drive Overview

Before discussing file systems, it is useful to understand what a hard drive is. Modern computers store data on hard drives (HDD) or solid‑state drives (SSD) so that information persists after power loss. For the purpose of this article, a hard drive can be imagined as a large array of data blocks, each block typically 4 KB in Linux.

2. What Is a File System?

The kernel reads and writes data in block units, which is not convenient for humans. To make storage intuitive, Linux abstracts two concepts: File and Directory. A file records which data blocks belong to it, while a directory records a list of files (and sub‑directories).

3. MINIX File System Implementation

3.1 MINIX Files and Directories

MINIX uses the minix2_inode structure to describe a file or directory:

struct minix2_inode {
    __u16 i_mode;      // mode
    __u16 i_nlinks;    // link count
    __u16 i_uid;       // owner UID
    __u16 i_gid;       // group GID
    __u32 i_size;      // file size
    __u32 i_atime;     // access time
    __u32 i_mtime;     // modification time
    __u32 i_ctime;     // creation time
    __u32 i_zone[10];  // block numbers belonging to the file
};

The i_zone array holds block numbers. It is divided into four parts: the first seven entries point directly to data blocks, the 8th entry is a single‑indirect pointer, the 9th is double‑indirect, and the 10th is triple‑indirect, allowing files to exceed 40 KB.

Directories are also represented by minix2_inode. The i_mode field distinguishes files ( S_IFREG) from directories ( S_IFDIR). Directory data blocks contain a list of minix_dir_entry structures:

struct minix_dir_entry {
    __u16 inode;   // index in the inode table (ignored here)
    char name[0];  // flexible array for the file name
};

3.2 MINIX File System Formatting

When a disk is formatted with MINIX, it is divided into several regions: Boot block: occupies one block (ignored for this discussion). Super block: one block storing file‑system metadata via the minix_super_block structure. Inode bitmap: tracks which inodes are in use. Block bitmap: tracks which data blocks are in use. Inode table: a series of minix2_inode objects, each representing a file or directory. Data block list: stores the actual file data.

The super block definition:

struct minix_super_block {
    __u16 s_ninodes;       // number of inodes
    __u16 s_nzones;        // number of zones (v1)
    __u16 s_imap_blocks;  // blocks used by inode bitmap
    __u16 s_zmap_blocks;   // blocks used by block bitmap
    __u16 s_firstdatazone; // first data zone number
    __u16 s_log_zone_size;
    __u32 s_max_size;      // maximum file size
    __u16 s_magic;         // magic number identifying MINIX FS
    __u16 s_state;         // file‑system state
    __u32 s_zones;         // number of zones (v2)
};

3.3 Reading a File

To read /home/file.txt, MINIX follows three steps:

Read the root directory : the root inode is the first entry in the inode table. Its directory list points to the home entry, whose inode index is 5.

Read the home directory : using inode index 5, locate the directory’s file list and find file.txt, whose inode index is 9.

Read file.txt content : fetch inode 9, then follow its i_zone pointers to the data blocks that store the file’s bytes.

Both the inode bitmap and the block bitmap are used during file creation to quickly locate free inodes and free data blocks.

4. Conclusion

By examining the simple MINIX file system, this article shows how a file system organizes storage on a hard drive, manages files and directories through inodes, and performs basic operations such as formatting and reading. Understanding MINIX provides a solid foundation for grasping the design of more complex Linux file systems.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxOperating SystemMINIXstorage
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.