File Systems, Storage and I/O
Learn how files, directories and inodes are organised, how disks and SSDs are scheduled, and how the OS handles I/O with interrupts and DMA.
Intermediate · about 4 hours · difficulty 2/5
Learn first: Memory Management and Virtual Memory
This area is asked less often than processes or memory, but a few questions come up reliably, and it builds intuition you will need for databases and system design.
File systems
- A file is a named sequence of bytes; a directory maps names to files. Know single-level, two-level and tree directory structures.
- Unix file systems store metadata (size, permissions, timestamps, block pointers) in an inode; the file name lives in the directory entry. Hard links share an inode, soft links point to a path.
- Allocation methods: contiguous (fast, fragments), linked (no fragmentation, slow random access), indexed (an index block of pointers, used by inodes with direct and indirect blocks).
- Free space management: bitmaps or free lists.
- Journaling protects metadata consistency after a crash by writing intent to a log first.
Disks and I/O
- HDD access time = seek time + rotational latency + transfer time. Disk scheduling algorithms: FCFS, SSTF, SCAN (elevator), C-SCAN, LOOK. Practise total head movement numericals.
- SSDs have no seek time but have erase-before-write and wear leveling.
- I/O techniques: polling (CPU keeps checking), interrupts (device signals the CPU), and DMA (device transfers data to memory directly, freeing the CPU).
- Buffering, caching and spooling (printing queues).
- RAID levels 0, 1, 5 and 10: striping, mirroring and parity trade-offs (optional but common in some companies).
Good enough to move on: you can explain what an inode holds, compute head movement for SCAN and C-SCAN, and describe why DMA exists.
Key concepts
- Files, directories and inodes
- Hard links vs soft links
- File allocation methods
- Disk scheduling (SCAN, C-SCAN, LOOK)
- Interrupts, polling and DMA
- Journaling
- RAID levels
Mini project
Write a disk scheduling simulator for FCFS, SSTF, SCAN, C-SCAN and LOOK that prints the head order and total movement, and on Linux use ls -i and ln to observe inode numbers for hard and soft links.
Check yourself
If you delete the original file, what happens to a hard link to it versus a soft link, and why?
Free resources
- OSTEP: Persistence chapters (OSTEP)
- GeeksforGeeks: Disk Scheduling Algorithms (GeeksforGeeks)