FAT32 DISKEXT4 DISKnameNOTES.TXTfirst cluster5BOOT2EOF344EOF56697EOF809EOF2dir3a4a5n16n27b89n3namenotes.txtinode12SUPERsize10000first block0length3start4096040958140959140960140961140962140963040958a40959a40960n140961n240962n340963
Left: FAT32 (directory entry, the FAT, data clusters)Right: ext4 (directory entry, inode with extent, block bitmap, data blocks)Cursor: how the kernel finds byte 9000 on each diskLeft, a FAT32 disk: the directory entry gives the first cluster, and the file allocation table, one entry per cluster, links the rest (5, 6, 9). Right, an ext4 disk: the directory entry gives inode 12, whose extent says three blocks from 40960. Byte 9000 is a walk on FAT and one sum on ext4. The cluster numbers 5, 6 and 9, inode 12 and block 40960 are example values chosen to be typical; how the FAT file came to be split around clusters 7 and 8 is not shown.

The file

  1. A disk is a long row of numbered blocks. A file system decides which blocks hold a file and how to find them again. Here notes.txt, 10,000 bytes, sits on two disks with 4 KiB blocks: FAT32 and ext4. It needs 3 blocks.

FAT32

ext4

Compare

What happens

;; step 1/11 · two-disks
file      notes.txt
size      10000 bytes
block     4096 bytes (4 KiB) on both disks
blocks    ceil(10000 / 4096) = 3

left    FAT32: directory entry -> table of next pointers
right   ext4:  directory entry -> inode -> extents

The cluster numbers 5, 6 and 9, inode 12 and block 40960 are example values chosen to be typical; how the FAT file came to be split around clusters 7 and 8 is not shown. FAT calls a block a cluster. Both the cluster size and ext4's block size (1 to 64 KiB, typically 4 KiB) are fixed when the disk is formatted; this example uses 4 KiB on both.