File Systems

⏱ 8 min✏️ Quiz at the end

What Is a File System?

Every time you save a document, download a photo, or install an app, the data has to be written to a storage device β€” but the device itself is just a large collection of sectors, each capable of holding a small fixed amount of data. A file system is the layer of software that sits between the operating system and the raw storage, giving data a meaningful structure: named files organised into folders, with a record of where every byte lives.

Without a file system, a storage device is simply an undifferentiated sea of 0s and 1s. The file system provides the map.

Directory Structures and Paths

File systems organise files into a hierarchy of directories (also called folders). At the top of the hierarchy sits the root directory β€” the single point from which every other location can be reached.

  • On Unix-like systems (Linux, macOS), the root is written as /.
  • On Windows, each drive has its own root, written as C:\, D:\, and so on.

A path is the address of a file or folder within this hierarchy. There are two kinds:

  • An absolute path starts at the root and lists every directory on the way to the file:
    /home/student/documents/essay.txt (Linux)
    C:\Users\Student\Documents\essay.txt (Windows)

  • A relative path starts from the current working directory β€” wherever the program or terminal is currently located. If you are already inside /home/student, the same essay can be reached with documents/essay.txt. Relative paths are shorter but ambiguous if you move to a different directory.

Common File Systems

Different operating systems use different file systems, each with its own trade-offs:

FAT32 (File Allocation Table, 32-bit) is one of the oldest still in common use. It is simple and universally supported β€” almost every device can read a FAT32 drive β€” but it has strict limitations: individual files cannot exceed 4 GB in size, and the total volume is capped at 8 TB. USB flash drives and memory cards are often formatted as FAT32 for compatibility.

NTFS (New Technology File System) is the default for modern Windows installations. It lifts the file-size restriction, supports file permissions and encryption, and records a transaction journal so that interrupted writes can be recovered. NTFS drives are readable on Linux and macOS but were not writable without third-party drivers until relatively recently.

ext4 (Fourth Extended File System) is the most widely used file system on Linux. It supports very large files and volumes, provides a journal for crash recovery, and is highly reliable. Most Linux distributions install onto ext4 by default.

exFAT (Extended FAT) was designed specifically for flash storage. It removes FAT32's 4 GB file-size limit while remaining broadly compatible across Windows, macOS, and Linux β€” making it the preferred format for large SD cards and external drives used across multiple operating systems.

How a File System Keeps Track of Files

When you create a file, the file system does three things:

  1. Finds free sectors on the storage device to hold the file's data.
  2. Writes the data into those sectors.
  3. Records an entry in a directory table (or equivalent index structure) that stores the file's name, size, creation date, and the location of its first sector.

This index is what lets the operating system find a file instantly by name, rather than scanning the entire device.

Fragmentation

When a file is first written, the file system tries to store it in contiguous (adjacent) sectors. Over time, as files are deleted and new ones created, gaps open up in various places. A large new file may not fit into a single gap, so the file system splits it across several non-contiguous regions β€” the file becomes fragmented.

On a traditional hard disk drive (HDD), fragmentation causes a real performance cost: the mechanical read head must physically move to multiple locations to read all the pieces of a single file. Defragmentation software reorganises the files so that each one occupies contiguous sectors, reducing the head movement required.

Solid-state drives (SSDs) store data in flash memory with no moving parts. Because every sector is accessed in the same amount of time regardless of location, fragmentation has almost no effect on SSD performance. Running a traditional defragmentation tool on an SSD is not only unnecessary but can shorten the drive's lifespan by causing extra write operations.

File Permissions

File systems that support permissions let administrators control who can do what with each file. The three fundamental permission types are:

  • Read (r) β€” the user can view the file's contents.
  • Write (w) β€” the user can modify, rename, or delete the file.
  • Execute (x) β€” the user can run the file as a program.

On Unix-like systems, permissions are set separately for three categories: the file's owner, the owner's group, and all other users. The classic display looks like rwxr-xr--, which means the owner can read, write, and execute; group members can read and execute; everyone else can only read.

Permissions are a key part of system security: by restricting write access, an administrator prevents unauthorised users from modifying important system files.

Key Words

  • File system β€” software that organises and manages how data is stored and retrieved on a storage device
  • Root directory β€” the top-level directory from which all other paths branch
  • Absolute path β€” a full path that begins at the root directory
  • Relative path β€” a path interpreted from the current working directory
  • Directory table β€” the file system's index, storing names and locations of all files
  • Fragmentation β€” when a file is split into non-contiguous chunks across the storage device
  • Defragmentation β€” reorganising files to restore contiguous storage (mainly relevant for HDDs)
  • Permissions β€” rules controlling which users can read, write, or execute a file