Understanding FAT and EXT File Systems

File System Structures: FAT and EXT

FAT File System

Components and Roles

  • Boot Sector: The first sector of the volume. Contains information about the file system’s size and structure, and information needed to boot MS-DOS.
  • First FAT (File Allocation Table): A table where each entry corresponds to a cluster on the disk. It tracks which clusters are used by files and how they are linked together.
  • Second FAT: A copy of the first FAT, providing redundancy in case of failure.
  • Root Directory: Contains entries for all files and subdirectories in the root. Each entry stores file attributes, including name, extension, size, and starting cluster.
  • Data Area: Stores the actual file and subdirectory data. Each cluster in this area has a corresponding entry in the FAT.

Displaying File Contents (e.g., foo.txt)

  1. The system searches the root directory for the file name and its starting cluster.
  2. It consults the FAT to locate the cluster on the disk.
  3. If the file occupies multiple clusters, the FAT is used to find the next cluster in the chain.

Root Directory vs. Subdirectory

The root directory has a fixed location and size within the file system. Subdirectories are files that store information about other files and subdirectories within them. They are not limited in size like the root directory.

Subdirectory vs. File

  • Subdirectory: A way to organize files and other subdirectories. It’s essentially a special type of file.
  • File: The basic unit of storage, containing a set of data.

FAT16 vs. FAT32

FAT32 uses 32-bit entries in the FAT (compared to 16-bit in FAT16), allowing for larger volumes and smaller clusters. The root directory in FAT32 is organized as a standard file.

Clusters

A cluster is a group of sectors, the smallest unit of disk storage that can be read or written. Files are stored in clusters, which are tracked by the FAT.

Fragmentation

Fragmentation occurs when a file is split across non-contiguous clusters on the disk. This can happen when files are deleted and new files are created, leaving gaps in the disk space. Fragmentation can slow down file access.

EXT2 File System

Superblock

The superblock contains metadata about the file system structure, such as block size and the number of inodes. It’s crucial for mounting the file system.

Inodes

An inode stores metadata about a file, including permissions, owner, size, and timestamps, but not the file name. Each file has a unique inode.

Block Bitmap

The block bitmap tracks which data blocks are allocated and which are free.

Structure and Components

  • Block Groups: The file system is divided into block groups, each containing:
    • A copy of the superblock
    • File system descriptors
    • A block bitmap
    • An inode bitmap
    • Data blocks

EXT2 vs. EXT3

EXT3 is a journaling file system built on top of EXT2. Journaling improves file system reliability by recording changes before they are applied to the disk. This reduces the risk of data corruption after a system crash.