Storage Devices and File System Structures
I am a Student, who finds beauty in simple things. I like to teach sometimes.
The selection and configuration of storage devices and their associated file systems are fundamental aspects of computer system architecture and performance. This document details the operational principles of common storage hardware, the characteristics of prevalent file systems, and the methods used for organizing storage space.
Storage Mediums: Contrasting Operational Principles
Modern computing primarily utilizes two types of storage devices: Hard Disk Drives (HDDs) and Solid State Drives (SSDs). Their internal mechanics and data handling methods differ substantially, leading to distinct performance profiles.
Hard Disk Drives (HDDs)
HDDs are electromechanical data storage devices that use magnetic storage to store and retrieve digital information using one or more rigid, rapidly rotating1 platters coated with magnetic material.2 Data is written to and read from the platters using magnetic heads, which are positioned on a moving actuator arm.
Operational Mechanics:
Platters and Spindle Motor: Platters, typically made of aluminum or glass, are coated with a thin magnetic layer. They rotate at high speeds, commonly 5400 to 7200 revolutions per minute (RPM), driven by a spindle motor. Higher RPMs generally correlate with faster data access.
Read/Write Heads and Actuator: The heads fly on an extremely thin air cushion nanometers above the platter surfaces. An actuator arm, controlled by a voice coil motor, rapidly moves the heads to the desired track on the platter.
Data Organization: Data is stored in concentric circles called tracks, which are further divided into sectors. A cylinder refers to the set of all tracks at a given head position across all platters.
Performance Characteristics:
Access Time: The time taken to access data is a sum of seek time (time for the head to move to the correct track), rotational latency (time for the desired sector to rotate under the head), and transfer time. Seek times and rotational latency are significant contributors to HDD latency, particularly for random access patterns.
Transfer Rate: Sustained data transfer rates are higher for sequential reads/writes than for random operations. Outer tracks typically have higher transfer rates than inner tracks due to more sectors per track.
Fragmentation: Over time, files can become fragmented (stored in non-contiguous sectors), which can degrade performance as the heads need to perform additional seeks.
HDDs offer high storage capacities at a relatively low cost per gigabyte. However, their mechanical nature makes them susceptible to physical shock and results in higher power consumption and audible operational noise compared to SSDs.
Solid State Drives (SSDs)
SSDs are storage devices that use integrated circuit assemblies as memory to store data persistently, typically using NAND flash memory. They contain no moving mechanical components.
Operational Mechanics:
NAND Flash Memory: Data is stored in an array of flash memory cells. These cells are organized into pages (typically 4KB to 16KB), and pages are organized into blocks (typically 128 to 512 pages).
Controller: A sophisticated controller manages data storage and retrieval, wear leveling, garbage collection, and error correction.
Data Access: Reads can be performed at the page level. Writes are more complex; data can only be written to erased (empty) pages. Erasing, however, must be done at the block level. This characteristic leads to the "read-modify-write" cycle for updating existing data or writing to a partially filled block, and can cause write amplification if not managed efficiently.
TRIM Command: The TRIM command allows an operating system to inform an SSD which blocks of data are no longer considered in use and can be wiped internally.3 This helps the SSD's garbage collection processes to manage storage space more effectively and maintain performance over time.
Performance Characteristics:
Access Time: Extremely low latency (microseconds range) due to the absence of mechanical movement, resulting in significantly faster random access performance compared to HDDs.
IOPS (Input/Output Operations Per Second): SSDs deliver vastly superior IOPS figures, making them highly effective for workloads with many small, random read/write requests.
Durability and Endurance: NAND flash cells have a finite number of program/erase (P/E) cycles. SSD controllers employ wear-leveling algorithms to distribute writes evenly across all memory cells, maximizing the drive's lifespan. Over-provisioning (allocating extra physical storage beyond the user-accessible capacity) also aids in endurance and performance.
SSDs offer substantially faster performance, lower power consumption, silent operation, and greater physical resilience than HDDs. Their cost per gigabyte is higher, though this gap has been narrowing.
Organizing Data: File System Fundamentals
A file system is a method and data structure that an operating system uses to control how data is stored and retrieved on a storage device.4 It manages files and directories, and the metadata associated with them.
The Function of a File System
Without a file system, data placed on a storage medium would be one large body of data with no way to tell where one piece of information stops and the next begins,5 or to retrieve any specific piece of data. By separating the data into individual pieces and giving each piece a name, the information is easily isolated and identified. It provides a hierarchical structure (directories and files), handles metadata (file names, permissions, timestamps, size), and tracks free and allocated space.
Common File System Types
Different file systems offer varied features, performance characteristics, and compatibility.
FAT32 (File Allocation Table 32)
FAT32 is a legacy file system that uses a File Allocation Table to manage the allocation status of clusters (the basic unit of disk allocation).
Structure: Consists of a boot sector, the FAT (usually two copies for redundancy), a root directory, and the data area where files and directories are stored. Directory entries contain file attributes and the starting cluster number of the file.
Limitations:
Maximum file size is 4 GiB minus 1 byte (232−1 bytes).
Maximum volume size is effectively 2 TiB with 512-byte sectors, though operating system utilities often impose smaller limits (e.g., Windows limits FAT32 formatting to 32 GiB).
Lacks modern features such as journaling (increasing risk of corruption from unexpected shutdowns) and robust file permissions.
Usage: Its broad compatibility makes it suitable for USB flash drives, memory cards, and external hard drives where interoperability across different operating systems (Windows, macOS, Linux) is a primary concern.
NTFS (New Technology File System)
NTFS is the standard file system for Microsoft Windows operating systems.
Structure: Centered around the Master File Table (MFT). The MFT is a special file that contains information about every file and directory on the NTFS volume. For small files and directories, the data itself can be stored within the MFT record (resident data).
Features:
Journaling ($LogFile): Maintains a log of changes to the file system metadata before they are written to the main file system structures. This improves recoverability in case of system crashes.
Security: Supports Access Control Lists (ACLs) for fine-grained control over file and directory permissions.
Large File and Volume Support: Supports very large files (theoretically 16 EiB minus 1 KB, practically limited by the OS, e.g., 256 TiB on Windows 10/11) and volumes (theoretically 256 TiB for 64KB clusters, practically 264−1 clusters).
Other Features: Includes support for file compression, encryption (Encrypting File System - EFS), sparse files, hard links, symbolic links, disk quotas, and Volume Shadow Copy Service (VSS).
Usage: Predominantly used on internal drives for Windows installations. Also used on external drives primarily accessed by Windows systems.
ext4 (Fourth Extended File System)
ext4 is a widely used journaling file system for Linux.
Structure: Uses inodes to store metadata about files (permissions, ownership, timestamps, size, and pointers to data blocks). Data blocks store the actual file content. Directories are special files that contain lists of filenames and their corresponding inode numbers.
Features:
Journaling: Provides different journaling modes (
journal,ordered,writeback) to balance performance and data integrity. Theorderedmode (default) ensures that data is written to the disk before its metadata is committed to the journal, offering a good compromise.Extents: Replaces the traditional indirect block mapping scheme for large files with extents. An extent is a contiguous range of physical blocks, which improves large file performance and reduces fragmentation.
Large File and Volume Support: Supports volumes up to 1 EiB (exbibyte) and individual files up to 16 TiB (tebibytes).
Delayed Allocation (allocate-on-flush): Defers the allocation of data blocks until the data is about to be written to disk. This allows the file system to make more informed decisions about block placement, potentially improving performance and reducing fragmentation.
Other Features: Includes persistent pre-allocation, multiblock allocator, checksums for journal and metadata integrity, and support for nanosecond timestamps.
Usage: The default file system for many Linux distributions, suitable for servers, desktops, and embedded systems running Linux.
Dividing Space: Understanding Disk Partitions
Disk partitioning is the act of dividing a hard disk drive or solid-state drive into multiple logical storage units referred to as partitions. Each partition can be managed independently and can have its own file system.
Purpose of Partitioning
Data Organization: Separating operating system files from user data or application files. This can simplify backup procedures and OS reinstallation.
Multiple Operating Systems: Allowing the installation of more than one operating system on a single physical drive, with each OS residing in its own partition.
Isolation: File system corruption in one partition is less likely to affect data in other partitions.
Specific Requirements: Some operating systems or applications may require or benefit from dedicated partitions.
Partitioning Schemes
Two main partitioning schemes define how partition information is structured on a disk: MBR and GPT.
MBR (Master Boot Record)
MBR is the traditional partitioning scheme used with BIOS-based computer systems.
Structure: The MBR is located in the first sector (512 bytes) of the disk. It contains a small amount of executable code for the boot loader and a 64-byte partition table.
Partition Types:
Primary Partitions: The MBR partition table can define up to four primary partitions. One of these can be marked as "active" to indicate to the BIOS which partition to boot from.
Extended Partition: To overcome the four-partition limit, one of the primary partition entries can be designated as an extended partition. This extended partition acts as a container.
Logical Partitions: Within an extended partition, multiple logical partitions (or logical drives) can be created. Each logical partition has its own Extended Boot Record (EBR) that defines it and points to the next logical partition.
Limitations:
Size Limit: Can only address disks up to 2 TiB in size (using 512-byte sectors and 32-bit addressing for Logical Block Addresses - LBAs).
Partition Limit: Limited to four primary partitions, or three primary partitions and one extended partition containing multiple logical partitions.
GPT (GUID Partition Table)
GPT is a modern partitioning standard that is part of the Unified Extensible Firmware Interface (UEFI) specification.
Structure: GPT uses Globally Unique Identifiers (GUIDs) to define partition types and partition entries themselves. It stores a primary GPT header and partition entry array at the beginning of the disk and a backup copy at the end of the disk for redundancy.
Advantages over MBR:
Disk Size: Supports significantly larger disk sizes (theoretically up to 9.4 ZB - zettabytes, assuming 512-byte sectors and 64-bit LBA addressing).
Number of Partitions: Allows for a much larger number of partitions without the need for an extended/logical partition structure. For example, Windows allows up to 128 partitions on a GPT disk. All partitions are effectively "primary" in nature.
Reliability: The redundant GPT headers and partition tables, along with Cyclic Redundancy Check (CRC32) checksums for header and partition table integrity, provide better protection against data corruption.
Boot Process: Designed to work with UEFI firmware, offering more robust and flexible boot capabilities.
GPT is the preferred partitioning scheme for modern computers, especially those with UEFI firmware and large storage devices.
Conclusion
The characteristics of storage hardware, such as HDDs and SSDs, define the raw performance capabilities for data access. File systems like FAT32, NTFS, and ext4 provide the necessary structure and logic to organize and manage data on these devices, each with specific features suited to different operating environments and requirements. Partitioning schemes like MBR and GPT allow for the flexible division and utilization of storage capacity. A sound understanding of these components is essential for effective system administration, performance optimization, and data management.