Layers:
device drivers (disk sector)
block I/O (partition, block)
file I/O (file, block)
file system (directory)
namespace (mounting file systems)
Multiple disks -glue-> volumes Volumes -split-> partitions
Partitions Record:
Master Boot Record (MBR): 1st sector on disk, 512 bytes, contains partition table and boot code, only support at most 4 primary partitions
GUID Partition Table (GPT): support up to 128 partitions, each partition entry is 128 bytes, with name support disks larger than 2TB, use CRC32 for integrity check
Partition: (start on byte 63 - because first 62 bytes are reserved for MBR for booting)
Paging Area (swap space): fake memory managed by OS
File System: persistent storage for files, managed by OS
Disk Data structure: (persistent data structure)
partition table
boot area (first block/track/cylinder on disk)
file system control block
free space map
inode (file control block)
directory: naming map from string to inode number
Memory Data structure: (non-persistent data structure)
Cache: partition table, directory name lookup cache
Open file table: file number, cursor position, allowed operations, etc. (both system-wide and per-process)
Directory: hash based map (name -> inode number)
Methods:
Contiguous: each file has pre-defined length (bad, not allow file growth)
Linked List: each files are multiple blocks chained together, dynamically allocate blocks (bad, hard to access file blocks at random, need to seek for each block)
FAT: linked list, but store next pointer in a separate linked list (so no link address in file block)
Indexed: treat file like virtual address, and use page table (except we don't need full table, we make 1st layer dynamically sized using linked list)

Issues of FAT:
Damage: if FAT is damaged, the whole file system is damaged (Solution: have a backup copy of FAT)
Performance:

Tricks:
you can predict what CPU request next (pre-fetching)
only give a portion of the cache to large file reads (which most likely only read once)
Table of Content