4.2.34 · D1Operating Systems
Foundations — File allocation — contiguous, linked, indexed (inode)
Before you can read the parent note (File allocation — contiguous, linked, indexed (inode)), you must be fluent in the tiny alphabet it uses without stopping to explain. This page builds each letter from nothing.
0. The disk as an array of boxes
The whole subject rests on one picture: the disk is a row of numbered boxes, all the same size.

1. — the block size (bytes per box)
- Plain words: how much data one box can hold.
- Picture: the height of a single box in the shelf figure — a container of capacity .
- Why the topic needs it: every "how many boxes does this file need?" and "which box holds byte 9000?" question is a division or multiplication by . It is the conversion rate between bytes (what users think in) and blocks (what disks think in).
2. A byte, and byte-numbering inside a file
- Picture: if a block is a box, a byte is one tiny cell inside it. A block of has cells numbered to .
- Why the topic needs it: users ask "give me byte 9000." The OS must translate that flat byte-number into (which box, which cell inside it). That translation is the heart of every scheme.
3. Logical block vs. physical block
This is the single most important distinction on the whole parent page. Two different numbering systems live side by side.

- Picture: the top row in the figure is the file's own pieces ; the arrows drop down to scattered boxes on the disk . Same data, two names.
- Why the topic needs it: allocation is the function that turns a logical into a physical . Every formula on the parent page — , — is just a different rule for that same arrow.
4. — file length in blocks
- Plain words: how many boxes this file needs.
- Picture: count the top-row pieces in the mapping figure — that count is .
- Why the topic needs it: contiguous allocation stores exactly the pair and nothing else. also tells us the valid range of : asking for block or beyond is reading past the end of the file.
5. Turning a byte number into (block, offset)
Now we can read the parent's very first worked example symbol-for-symbol.

- Picture: lay the file's bytes end to end and slice every bytes into a box. The floor tells you which box a byte fell into; the modulo tells you how far in (the cell).
6. — the pointer size
- Picture: a small arrow drawn inside a box, pointing at another box. Drawing that arrow costs bytes of the box's own space.
- Why the topic needs it:
- In linked allocation the pointer lives inside each data box, so usable data is .
- In indexed allocation an index box is filled entirely with pointers, so it holds of them.
7. — pointers per block
- Picture: an empty box divided into little slots, each slot holding one arrow.
- Why the topic needs it: this single number drives the entire inode size calculation. One index box reaches data blocks; each extra level of indirection multiplies reach by again → , , .
- Numbers: with , : .
8. Big-O — the cost language ( vs )

- Picture: two curves against file position. is a flat line (always one lookup). is a rising straight line (block costs reads).
- Why the topic needs it: it is the yardstick the whole comparison table uses. "Fast random access" means ; "slow random access" means . Contiguous and indexed are ; plain linked is .
9. Two words you'll meet: fragmentation & inode
Prerequisite map
Every arrow says "you need the left idea before the right one makes sense." Everything funnels into the three schemes on the parent note.
Related vault topics
- Free Space Management (bitmap, free list) — how the OS finds a free box to hand out.
- File Systems (ext4, FAT, NTFS) — real systems that implement these schemes.
- Directory Structure — where the "start block" / "inode number" is actually stored.
- Disk Scheduling — the cost of a "seek" that makes contiguous layout attractive.
- Virtual Memory Paging — the same logical→physical mapping idea, for RAM.
- 🇮🇳 Hinglish version
Equipment checklist
A block is…
a fixed-size chunk of disk, the smallest unit read/written; addressed by a single integer.
stands for…
block size — the number of bytes in one block (e.g. 4096).
Logical block means…
the -th piece of one particular file, counted from 0 (the file's private numbering).
Physical block means…
the real box number on the disk, shared by all files (the actual address).
The job of "file allocation" is…
to provide the map from logical block to physical block .
is…
the file's length in blocks; valid indices are .
Byte lives in which logical block and offset?
block , offset .
(floor) does…
rounds down to the nearest whole number.
gives…
the remainder after dividing by .
is…
pointer size — bytes needed to store one block address (e.g. 4).
counts…
how many pointers (block addresses) fit in one full block.
With ,
.
vs mean…
constant work regardless of size, vs. work growing in proportion to block index.