4.2.35 · D1Operating Systems

Foundations — ext4 structure — superblock, block groups, inodes

2,478 words11 min readBack to topic

Before you can read the parent note comfortably, you need to own every word and symbol it throws at you. This page builds each one from nothing, in the order they depend on each other.


0. The picture everything sits on: the block array

The number written under a box is its block number — its address. When the parent says "physical block 5000", it means "the 5000th box in this row". That is all a raw disk is: no files, no folders, just numbered boxes.


1. Bytes, KiB, MiB, GiB — the units

Why the topic needs this: the whole "128 MiB per group, 80 groups on a 10 GiB disk" arithmetic is just unit conversion. Get the units wrong and every number is wrong.


2. The bit, and the picture of a bitmap

The key counting fact (used everywhere in the parent): one block of bytes holds So a bitmap that is exactly one block can describe exactly blocks. Hold that number — it is where "blocks per group" comes from. But first: what is a group?


3. The block group — ext4's neighbourhood

With "group" now meaning something concrete, the arithmetic in the next section — "which group is inode in?" — is just asking which neighbourhood to walk to.


4. Floor, mod, and 1-based counting — the arithmetic tools

The parent computes which group an inode lives in. That needs two operations you may not have seen written as symbols.


5. Hexadecimal and the magic number 0xEF53


6. Byte offset — "how far in from the start"


7. Pointer, extent, and the range picture


8. Words you'll meet without derivation (quick glossary)

These connect ext4 up to the Virtual File System, the OS layer that lets many filesystems present the same "files and folders" interface.


How these foundations feed the topic

Read the map below top to bottom: an arrow "X → Y" means "you must understand X before Y makes sense." Start at the four roots with no incoming arrows (units, the block picture, floor/mod, and 1-based vs 0-based). Trace any path downward and you arrive at the same destination — the box labelled ext4 structure, which is the parent topic. The four boxes pointing straight into it are exactly the four questions the parent answers: how big is a group, which group is my inode in, where is the superblock, and how does an inode reach its data.

Units KiB MiB GiB

Block = fixed box, size B bytes

Bit and Bitmap

Byte offset

Block group = neighbourhood

Blocks per group = 8B

Floor and Mod

Which group is inode N

1-based vs 0-based

Superblock at offset 1024

Hex 0xEF53

Pointer then Extent

Inode finds data

ext4 structure


Equipment checklist

Test yourself — cover the right side and answer out loud.

What is a block, and what is ?
A fixed-size chunk of disk (one identical box); is its size in bytes, commonly 4096.
What does mean in "blocks "?
The total number of blocks on the disk; the last block's number is because counting starts at 0.
What is a block group?
An equal-sized neighbourhood of the disk bundling a block bitmap, inode bitmap, inode table, and data blocks — a self-contained mini-filesystem.
Why does ext4 use block groups?
To keep a file's bookkeeping near its data (less seek), bound bitmap size, and reduce fragmentation.
How many bits fit in one block of bytes?
bits (8 bits per byte) — the reason a group holds blocks.
What does bit mean in a block bitmap?
Block in this group is used (0 = free).
What does do and why use it here?
Rounds down to a whole number; turns a fractional group count into the whole group index.
What does give, and what does it tell us?
The remainder of ; the position within the group.
Why subtract 1 in ?
Inodes are 1-based but table slots are 0-based; the converts between them.
bytes.
bytes.
What is 0xEF53 and where does it live?
The ext magic number (a fingerprint) stored in the superblock to confirm the filesystem type.
Where (byte offset) is the primary superblock, and why not offset 0?
Offset 1024; the first 1024 bytes are reserved for a boot sector.
What is an extent and why is it better than pointers?
One record mapping a contiguous run of logical blocks to physical blocks; far fewer records than one-pointer-per-block.
Where is a file's name stored — inode or directory?
The directory entry (name → inode number); never the inode.
Recall One-line summary

A disk is numbered boxes; units measure them, ext4 chops them into block groups, a bitmap tracks which are free ( per block), floor/mod with a locate an inode's group, a hex magic number at offset 1024 identifies the filesystem, and extents map file blocks to physical boxes — that's the whole vocabulary of ext4.