Reading Time: 3 minutes

File systems are the foundation of how computers organize, store, and retrieve data on physical storage devices like hard drives and SSDs. From saving a document to launching an application, file systems silently handle it all. In this article, we explore how they work behind the scenes.

1. What Is a File System?

A file system is a software layer that manages how data is stored and accessed on storage devices. It acts as a bridge between user-level operations (e.g., opening a file) and the physical bytes on a disk.

Examples of file systems:

  • FAT32 – simple and widely supported
  • NTFS – used in Windows
  • ext4 – default in most Linux distributions
  • APFS – optimized for macOS and SSDs

2. How Data Is Stored

Blocks, Sectors, and Clusters

Disks are divided into physical sectors (usually 512 bytes or 4KB), grouped into clusters or allocation units. Large files are stored across multiple blocks, and even small files occupy a full block.

Indexing and Tables

File systems use indexing structures like:

  • FAT (File Allocation Table)
  • MFT (Master File Table in NTFS)
  • Inodes and B-trees (in ext4, APFS)

These tables track where each file’s data blocks are located on disk.

3. How Data Is Retrieved

Retrieving a file involves locating its directory entry, reading its metadata (size, location), and following pointers to the actual blocks of data. The OS then assembles the data and provides it to the user or application.

4. Metadata and File System Structure

Metadata describes a file’s properties:

  • File name and extension
  • Permissions and ownership
  • Timestamps (created, modified)
  • Block locations

Directories are stored as special files with pointers to other files or folders. Many modern file systems use journaling to keep track of changes and protect against data corruption.

5. Comparison of Popular File Systems

File System OS Support Max File Size Journaling Notes
FAT32 Windows, Linux 4 GB No Highly compatible but limited
NTFS Windows 16 TB+ Yes Supports permissions, recovery, compression
ext4 Linux 16 TB Yes Reliable and widely used on Linux
APFS macOS 8 EB Yes Built for SSDs, supports snapshots

6. Step-by-Step: Saving a File

  1. The user creates or modifies a file.
  2. The OS sends data to the file system driver.
  3. The file system splits the data into blocks.
  4. Free blocks are found and allocated.
  5. The index table (e.g., MFT or inode) is updated.
  6. Metadata is written (timestamps, size, permissions).

7. Step-by-Step: Opening a File

  1. The user requests to open a file (by path).
  2. The OS parses the directory structure to locate the file entry.
  3. Metadata is loaded to identify the location of data blocks.
  4. Blocks are read from the disk.
  5. The data is reconstructed and sent to the application.

8. SSD vs HDD Considerations

SSD: Offers fast access times but suffers from limited write cycles. File systems use TRIM commands to avoid performance degradation.

HDD: Slower mechanical access but supports many writes. File fragmentation can cause delays in reading scattered blocks.

Modern file systems are optimized for the underlying hardware.

9. Common File System Issues

  • Fragmentation – scattered files slow down HDDs.
  • Corrupted metadata – file tables may become unreadable.
  • Unsafe shutdowns – can cause journal inconsistencies.
  • Recovery tools – such as chkdsk, fsck, TestDisk can repair damaged file systems.

Conclusion

File systems play a vital role in ensuring our data is safely stored, organized, and retrievable. Understanding how they work helps you manage files more effectively and troubleshoot issues when they arise. Whether you’re formatting a USB stick or recovering lost data, the file system is always at the core of the process.

Resources