Disk Structure & Layout

Exploring how physical storage is organized through CHS addressing, LBA, disk geometry, and partition schemes like MBR and GPT.

published: reading time: 26 min read author: GeekWorkBench

Disk Structure & Layout

Before bytes become files, before files become directories, there’s the raw geometry of spinning platters and precise magnetic encoding. Understanding how disks are structured—how the operating system speaks to raw metal—explains a lot about why file systems work the way they do. This isn’t ancient history; the concepts directly impact how we partition, format, and troubleshoot storage today.

Modern SSDs have abstracted away much of this complexity, but the underlying models persist. MBR and GPT partition tables still define how drives are divided. Understanding CHS and LBA explains why certain limits exist and why a “2TB limit” haunts older systems. The geometry of storage shapes everything from file system choices to backup strategies.

Introduction

When to Use / When Not to Use

Understanding disk structure is essential for system administration, troubleshooting, and performance optimization.

When disk structure knowledge matters:

  • Setting up new systems with proper partitioning
  • Troubleshooting boot issues and partition problems
  • Recovering data from damaged partitions
  • Working with legacy systems that hit addressing limits
  • Configuring RAID and understanding redundancy

When you can ignore it:

  • Working purely with cloud block storage (abstracted away)
  • Using container systems with volumes
  • Dealing with fully abstracted storage (some NAS systems)
  • High-level application development (file I/O handles this)

Architecture or Flow Diagram

graph TD
    A[Logical Block Address LBA] --> B[Host System]
    B --> C[Storage Controller]
    C --> D[Disk Firmware]
    D --> E[Physical Media]

    F[CHS Geometry] --> C
    G[Partition Table MBR/GPT] --> F

    style A stroke:#ff00ff,stroke-width:2px
    style G stroke:#ff00ff,stroke-width:2px

The diagram shows the translation from logical addressing (LBA) to physical media. The partition table sits between the host’s view of the drive and the actual physical layout.

Core Concepts

CHS Addressing: The Old Geometry

Cylinder-Head-Sector (CHS) addressing was the original way to specify disk locations. Each component maps to a physical aspect of the drive:

  • Cylinder: The set of tracks at the same radial position across all surfaces
  • Head: Which read/write head is active (which surface)
  • Sector: Which sector within the track (typically 512 bytes)
graph TD
    A[Disk Platter] --> B[Concentric Tracks]
    B --> C[Track 0 outermost]
    B --> D[Track N innermost]

    E[Cylinder] --> F[Track on Surface 0]
    E --> G[Track on Surface 1]
    E --> H[Track on Surface N]

    style C stroke:#ff00ff
    style D stroke:#ff00ff

With CHS, to read address (cylinder 1024, head 3, sector 50), the controller moves heads to the third surface, positions at the 1024th track, and waits for sector 50 to rotate under the head.

Limitations:

  • Maximum 8GB with standard CHS (1024 cylinders × 16 heads × 63 sectors × 512 bytes)
  • Drives often reported fake geometry to work around BIOS limits
  • Translation layers made the situation more complex

LBA: The Modern Standard

Logical Block Addressing (LBA) simplifies everything to a single number: the sequential sector number from zero.

  • LBA 0 = first sector (cylinder 0, head 0, sector 1)
  • LBA 1 = second sector
  • LBA n = (n+1)th sector
// LBA to CHS conversion (simplified)
void lba_to_chs(uint32_t lba, uint16_t *cyl, uint8_t *head, uint8_t *sector) {
    uint32_t sectors_per_track = 63;  // Traditional value
    uint32_t tracks_per_cylinder = 16; // Traditional value

    *sector = (lba % sectors_per_track) + 1;
    uint32_t temp = lba / sectors_per_track;
    *head = temp % tracks_per_cylinder;
    *cyl = temp / tracks_per_cylinder;
}

LBA-48 (48-bit LBA) supports drives up to 144 petabytes—more than enough for current storage needs.

Disk Geometry and Zones

Modern drives organize sectors into zones:

graph LR
    A[Zone 0<br/>Outer tracks<br/>Higher density<br/>Faster] --> B[Zone 1]
    B --> C[Zone N<br/>Inner tracks<br/>Lower density<br/>Slower]

    style A stroke:#ff00ff,stroke-width:2px
    style C stroke:#ff00ff,stroke-width:1px

Outer zones store more sectors per track than inner zones. This “zoned recording” maximizes capacity while maintaining constant data rate across the drive. The firmware handles the translation, presenting a uniform LBA space to the host.

Partition Schemes

MBR: The Legacy Standard

Master Boot Record occupies the first 512 bytes of the disk:

graph TD
    A[MBR Structure 512 bytes] --> B[Boot Code 446 bytes]
    A --> C[Partition Table 64 bytes]
    A --> D[Magic Number 0x55AA 2 bytes]

    C --> E[Partition 1 16 bytes]
    C --> F[Partition 2 16 bytes]
    C --> G[Partition 3 16 bytes]
    C --> H[Partition 4 16 bytes]

    style B stroke:#ff00ff
    style D stroke:#ff00ff

Each partition entry stores:

  • Boot flag: 0x80 for bootable, 0x00 otherwise
  • Starting CHS: First sector location
  • Partition type: File system identifier (0x83 = Linux, 0x07 = NTFS, 0x0C = FAT32)
  • Ending CHS: Last sector location
  • Starting LBA: First sector as 32-bit value
  • Size: Number of sectors as 32-bit value

MBR Limitations:

  • Maximum 2TB per partition (32-bit sector count)
  • Maximum 4 primary partitions (or 3 primary + 1 extended)
  • No backup partition table
  • No checksum for partition data

GPT: The Modern Standard

GUID Partition Table removes MBR’s limitations:

graph TD
    A[GPT Layout] --> B[Protective MBR 512 bytes]
    A --> C[Primary GPT Header 92 bytes]
    A --> D[Primary GPT Array 16KB min]
    A --> E[Backup GPT Header]
    A --> F[Backup GPT Array]

    style B stroke:#00fff9
    style C stroke:#ff00ff
    style E stroke:#00fff9
    style F stroke:#00fff9

GPT Advantages:

  • Supports drives up to 8ZB (using 64-bit sector addresses)
  • Unlimited partitions (practical limit ~128)
  • Backup GPT headers at end of disk
  • CRC32 checksums for integrity
  • Unique partition GUIDs for reliable identification

Partition Type Identifiers

Common MBR partition types:

TypeDescription
0x83Linux
0x82Linux swap
0x8ELinux LVM
0x07Windows NTFS
0x0CFAT32
0xEEGPT protective
0xEFEFI System Partition

Production Failure Scenarios

Scenario 1: MBR Corruption

What happened: A server’s first drive failed catastrophically. The data recovery team retrieved most files, but the partition table was gone. Without it, the operating system couldn’t find where partitions began and ended.

Detection:

# Check for valid GPT/MBR signature
sudo fdisk -l /dev/sda | grep -E "Disklabel|GPT|MBR"

# Try to identify partitions with testdisk
sudo testdisk /dev/sda

Mitigation:

  • Backup partition table regularly:

    sudo sfdisk -d /dev/sda > partitions_backup.txt
  • Use GPT which has backup headers

  • Keep rescue media with partition tools

  • Clone partition table when setting up similar systems

Scenario 2: Overlapping Partitions

What happened: A user attempted to resize a partition using a disk management tool. The tool crashed mid-operation, leaving overlapping partitions. The kernel refused to mount the file system, and fsck failed.

Detection:

# Use parted to detect overlaps
sudo parted /dev/sda
(parted) align-check optimal 1  # Check partition 1 alignment
(parted) align-check optimal 2  # Check partition 2 alignment

# Check partition table for overlaps
sudo gdisk -l /dev/sda | grep -A 4 "unique GUIDs"

Mitigation:

  • Always backup before partition operations
  • Use tools that handle interruptions gracefully (parted vs fdisk)
  • Use rescue mode with TestDisk for recovery
  • Consider recreating partitions and restoring from backup

Scenario 3: 2TB Limit Encounter

What happened: A company purchased a 4TB drive for backup. The system only saw 2TB. The drive was using MBR partitioning, which maxes out at 2TB with 512-byte sectors.

Detection:

# Check partition table type
sudo parted /dev/sda
(parted) print

# See output like:
# Model: ATA ST4000DM000-1F2 (scsi)
# Disk /dev/sda: 4000GB
# Partition table: msdos  <-- This is MBR!

Mitigation:

  • Convert to GPT using gdisk:

    sudo gdisk /dev/sda
    # Type 'w' to convert MBR to GPT (backup MBR first!)
  • For boot drives, ensure UEFI boot support exists

  • Plan for GPT on drives larger than 2TB

Trade-off Table

AspectMBRGPTNotes
Max Drive Size2TB8ZBMBR limited by 32-bit sector count
Max Partitions4 primary128 primaryGPT practical limits
BackupNoneHeader + array at endAutomatic with GPT
Boot SupportBIOS onlyUEFI required for bootLegacy systems use MBR
IntegrityNoneCRC32 checksumsGPT validates structure
Partition IDs1-byte type128-bit GUIDGPT more precise

Implementation Snippet

Reading Partition Table with Python

import struct

def read_mbr(device_path):
    """Read and parse MBR partition table."""
    with open(device_path, 'rb') as f:
        # Read boot sector (512 bytes)
        boot_sector = f.read(512)

        # Verify magic number
        if boot_sector[510:512] != b'\x55\xaa':
            raise ValueError("Invalid MBR signature")

        # Parse partition table (64 bytes starting at offset 446)
        partitions = []
        for i in range(4):
            entry_offset = 446 + (i * 16)
            entry = boot_sector[entry_offset:entry_offset + 16]

            if entry[0] == 0:  # Empty partition
                continue

            partition = {
                'boot_flag': entry[0],
                'start_head': entry[1],
                'start_sector_cylinder': struct.unpack('<H', entry[2:4])[0],
                'type': entry[4],
                'end_head': entry[5],
                'end_sector_cylinder': struct.unpack('<H', entry[6:8])[0],
                'start_lba': struct.unpack('<I', entry[8:12])[0],
                'size_sectors': struct.unpack('<I', entry[12:16])[0],
            }
            partitions.append(partition)

        return partitions

def print_partitions(device_path):
    """Display partition information."""
    TYPE_NAMES = {
        0x07: 'NTFS/HFS+',
        0x83: 'Linux',
        0x82: 'Linux Swap',
        0x8E: 'Linux LVM',
        0x0C: 'FAT32',
        0xEE: 'GPT Protective',
        0xEF: 'EFI',
    }

    parts = read_mbr(device_path)
    for i, p in enumerate(parts):
        ptype = TYPE_NAMES.get(p['type'], f'Unknown (0x{p:02x})')
        size_gb = (p['size_sectors'] * 512) / (1024**3)
        print(f"Partition {i+1}: {ptype}, Start LBA: {p['start_lba']}, "
              f"Size: {size_gb:.2f} GB")

if __name__ == "__main__":
    import sys
    print_partitions(sys.argv[1] if len(sys.argv) > 1 else "/dev/sda")

Inspecting GPT with bash

#!/bin/bash
# gpt_inspect.sh - Display GPT partition information

DEVICE=${1:-/dev/sda}

echo "=== GPT Partition Table for $DEVICE ==="

# Check for GPT
if ! sudo gdisk -l "$DEVICE" 2>/dev/null | grep -q "GPT:"; then
    echo "Not a GPT disk"
    exit 1
fi

# List partitions
sudo gdisk -l "$DEVICE" <<< "p"

# Show partition details
echo ""
echo "=== Detailed Partition Info ==="
for part_num in $(seq 1 128); do
    info=$(sudo gdisk -l "$DEVICE" 2>/dev/null | grep "^$part_num ")
    if [ -n "$info" ]; then
        echo "$info"
    fi
done

# Show backup GPT location
echo ""
echo "=== GPT Backup Header Location ==="
sudo gdisk -l "$DEVICE" | grep -E "Backup|Sector"

Observability Checklist

Monitoring disk structure health:

  • fdisk -l /dev/sdX: List partition table and verify signatures
  • gdisk -l /dev/sdX: Show GPT information and GUIDs
  • parted /dev/sdX print: Display partition layout
  • lsblk: Show block devices and their hierarchy
  • blkid: Show UUID and TYPE for each partition

Key checks:

# Verify MBR/GPT signatures
sudo fdisk -l /dev/sda 2>/dev/null | grep "Disklabel"
# Should show: Disklabel type: dos (MBR) or gpt

# Check for backup GPT
sudo gdisk -l /dev/sda | grep "Backup GPT"
# Should show location at end of disk

# Monitor partition alignment
sudo parted /dev/sda align-check opt
# Should show "1 aligned" for each partition

# Verify partition doesn't exceed disk size
cat /proc/partitions

Common Pitfalls / Anti-Patterns

Secure Partition Deletion

Simply deleting partitions doesn’t erase data. For compliance:

# Overwrite entire drive with zeros (slow but thorough)
sudo dd if=/dev/zero of=/dev/sda bs=1M status=progress

# Use random data for better security
sudo shred -v -n 1 /dev/sda

# For quick format (not secure)
sudo hdparm --secure-erase-all /dev/sda

UEFI Secure Boot Considerations

  • EFI System Partition (ESP) must be FAT32
  • ESP size recommendation: 100-500MB
  • ESP must be flagged as “EFI boot” in partition table
# Create EFI partition with gdisk
# Type: EF00 (EFI System Partition)
sudo gdisk /dev/sda
Command: n
Partition number: 1
First sector: [default]
Last sector: +512M
Hex code: EF00

Partition UUIDs for Compliance

GPT assigns unique GUIDs to each partition. Document these:

# List partition UUIDs
sudo blkid

# Or with gdisk
sudo gdisk -l /dev/sda | grep -E "Partition GUID|unique"

# Export for documentation
sudo blkid -s UUID -s TYPE -s LABEL > partition_ids.txt

Common Pitfalls / Anti-patterns

1. Converting MBR to GPT Without Backup

# BAD: Converting without backup
sudo gdisk /dev/sda
Command: m  # Load MBR, convert in place
Command: w  # WRITE (data loss possible if interrupted!)

# GOOD: Backup first, then convert
sudo sfdisk -d /dev/sda > mbr_backup.txt
sudo dd if=/dev/sda of=mbr_sector_512.img bs=512 count=1
# Now safe to convert

2. Creating Partitions That Overlap

# BAD: Manually calculating can cause overlap
# Partition 1: 2048-4096 (1MB)
# Partition 2: 4095-8192 (overlaps!)
#                 ^^^ Should be 4096, not 4095

# GOOD: Use tools that prevent overlap
sudo parted /dev/sda mkpart primary ext4 2048s 4096s
sudo parted /dev/sda mkpart primary ext4 4096s 8192s
# parted validates and prevents overlap

3. Ignoring Alignment

Modern disks and SSDs require 1MB alignment (2048 sectors of 512 bytes):

# BAD: Default alignment might be wrong
sudo fdisk /dev/sda  # May create misaligned partitions

# GOOD: Specify alignment
sudo parted /dev/sda mkpart primary ext4 2048s 100%
# Use sector numbers that are multiples of 2048

4. Boot Flag Confusion

MBR uses the boot flag to indicate which partition is bootable. Modern UEFI ignores this:

# Set boot flag (only matters for BIOS boot)
sudo fdisk /dev/sda a 1  # Set boot flag on partition 1

# Clear boot flag
sudo fdisk /dev/sda a 0  # Clear boot flag

Quick Recap Checklist

  • CHS addressing maps to physical disk geometry; LBA is the logical replacement
  • MBR supports max 2TB and 4 primary partitions; GPT removes these limits
  • GPT includes backup headers at end of disk for recovery
  • Always backup partition table before making changes
  • Convert MBR to GPT for drives larger than 2TB
  • Use sector alignment of 2048 (1MB) for modern disks
  • Partition type codes identify the file system; GPT uses 128-bit GUIDs

Interview Questions

1. Explain the difference between CHS and LBA addressing.

CHS (Cylinder-Head-Sector) addressing maps directly to physical disk geometry. You specify which cylinder (radial track position), which head (which surface), and which sector within the track. This was the original addressing method but has limitations: it maxes out around 8GB with standard BIOS limits, and drives often lie about their geometry through translation layers.

LBA (Logical Block Addressing) treats the disk as a simple linear array of sectors numbered from 0. The drive firmware translates LBA addresses to physical geometry internally. LBA-28 supports up to 128GB, LBA-48 supports up to 144PB. This is the universal standard today.

The key insight: applications see LBA, drives handle the translation to CHS internally.

2. What are the key differences between MBR and GPT partition tables?

MBR (Master Boot Record) occupies the first 512 bytes of the disk and contains:

  • Boot code (446 bytes)
  • Partition table (64 bytes) — only 4 entries
  • Magic number (0x55AA)

Limitations: 2TB max partition size, 4 primary partitions, no backup, no integrity checking.

GPT (GUID Partition Table) uses:

  • Protective MBR (first 512 bytes) for legacy compatibility
  • Primary GPT header at sector 1 (92 bytes)
  • Partition entry array (minimum 16KB, typically 128 entries of 128 bytes each)
  • Backup GPT at end of disk

Advantages: 8ZB max, 128+ partitions, CRC32 checksums, unique GUIDs for each partition.

3. Why can't a 3TB drive work with MBR partitioning?

MBR stores partition size as a 32-bit sector count. With standard 512-byte sectors, this limits the maximum addressable capacity to:

2^32 sectors × 512 bytes/sector = 2,199,023,255,552 bytes ≈ 2.2 TB

A 3TB drive has more than 2^32 sectors, so the partition size value overflows. The operating system either shows only 2TB or behaves erratically.

The solution is GPT partitioning, which uses 64-bit sector counts (allowing 8ZB) and doesn't have this limitation.

4. What happens when you delete a partition in Linux?

When you delete a partition (e.g., with fdisk or parted):

  1. The partition table entry is cleared (zeroed out)
  2. No data on disk is modified — only the partition table
  3. Until you run partprobe or reboot, the kernel may still use old table
  4. Data remains on disk but is now "orphaned"

To actually recover the partition, tools like TestDisk scan the disk for file system signatures and can often reconstruct the partition table by finding the begin and end markers of each partition.

This is why backing up the partition table before making changes is critical—you can restore it if something goes wrong.

5. How would you recover a accidentally deleted GPT partition?

Recovery steps:

  1. Don't write anything to the disk — every write could overwrite backup GPT structures
  2. Backup current state: sudo sfdisk -d /dev/sda > current_state.txt
  3. Use TestDisk: sudo testdisk /dev/sda
    • Select the disk and choose EFI/GPT
    • Analyze to find partition boundaries
    • Search for lost partitions
    • Write the recovered partition table
  4. Or use gdisk: The backup GPT at end of disk can be restored: sudo gdisk /dev/sda then r for recovery, e to load backup GPT
  5. Verify: sudo partprobe and mount -a

Prevention is better: always sfdisk -d /dev/sda > backup.txt before changes.

6. What is LBA-48 and why was it needed?

LBA-48 extended the original LBA standard (LBA-28) from 28 bits to 48 bits of sector addressing. This was necessary because:

2^28 sectors × 512 bytes = 128 GB maximum addressable capacity

As drives grew past 128GB, a new standard was required. LBA-48 uses 48-bit sector addresses:

2^48 sectors × 512 bytes = 144 PB (petabytes)

LBA-48 support is required for drives larger than 128GB. Most modern drives and controllers support LBA-48, and the operating system automatically negotiates the highest supported mode.

7. Why do SSDs still show the same partition schemes (MBR/GPT) as HDDs?

SSDs present themselves as block devices just like HDDs—they share the same logical interface. The partition scheme (MBR or GPT) is a software concept, not a hardware requirement. SSDs use:

  • Same addressing: SSDs use LBA addressing just like HDDs, making them compatible with existing partitioning tools
  • Wear leveling: The SSD controller handles physical to logical block mapping internally, presenting a clean linear LBA space to the host
  • Trim and garbage collection: The SSD manages free space internally; partition alignment just ensures efficient block erasure

The partition table still matters for boot loaders, file system boundaries, and OS recognition, but the underlying storage technology is abstracted away.

8. What is the difference between primary, extended, and logical partitions in MBR?

Primary partitions: The only partitions that can boot an OS. MBR supports maximum 4 primary partitions. All data storage happens in primary partitions.

Extended partition: A special primary partition that acts as a container. It consumes one of the 4 primary partition slots but doesn't hold data directly—instead, it holds logical partitions.

Logical partitions: Created within the extended partition. The extended partition's partition table (stored differently from MBR's main table) can hold many logical partitions—practical limit is typically 12-15 due to drive geometry constraints.

This design allowed more than 4 partitions while maintaining backward compatibility. A typical setup: sda1 (Windows), sda2 (Linux), sda3 (extended containing sda5, sda6, sda7 for data).

9. How does sector size (512-byte vs 4KB) affect storage capacity calculations?

Storage capacity is calculated as: total sectors × sector size

With 512-byte sectors, a drive with 4,094,496,000 addressable sectors = 2TB (4,094,496,000 × 512 = 2,199,023,555,200 bytes).

With native 4KB sectors, the same drive would have 511,812,000 addressable sectors = 2TB (511,812,000 × 4096 = 2,097,152,000,000 bytes).

4KB native drives (4Kn): The drive reports 4KB sectors to the host. Benefits: more efficient for large sequential I/O, better for RAID alignment.

512e (512-byte emulation): The drive internally uses 4KB sectors but presents 512-byte sectors to the host for compatibility. Performance can degrade if writes aren't aligned to 4KB boundaries.

10. What is the EFI System Partition (ESP) and what are its requirements?

The EFI System Partition (ESP) is a partition required for UEFI boot. It contains:

  • Bootloader files (e.g., EFI/Microsoft/Boot/bootmgfw.efi)
  • UEFI firmware drivers for file systems
  • Startup NVRAM configuration

Requirements:

  • File system: Must be FAT32 (per UEFI specification)
  • Size: 100MB minimum, 500MB recommended
  • Partition type: GPT partition type GUID = C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI System Partition)
  • Location: Must be accessible without additional drivers (typically first partition)

Without a properly configured ESP, UEFI systems cannot boot. Some Linux installers create a 1GB ESP to accommodate multiple OS bootloaders.

11. How does BIOS disk I/O differ from direct ATA/IDE access in OS development?

BIOS disk I/O (int 0x13): Works only in 16-bit real mode, uses 24-bit segment:offset addressing (limited to 8GB), no DMA support, slow. Once the OS switches to protected mode, BIOS interrupts are unavailable — this is why OS developers must use direct I/O.

Direct ATA/IDE: The IDE controller exposes I/O ports (0x1F0-0x1F7 for primary channel). Reading/writing to these ports triggers DMA transfers, supports LBA48 addressing (>137GB), and works in protected mode. A minimal driver writes ATA registers to select drive, sector, and count, then triggers I/O. The in/out assembly instructions access these ports directly.

Modern SATA uses AHCI (Advanced Host Controller Interface) with memory-mapped registers and command queuing (NCQ) — a significant upgrade from legacy IDE.

12. What is the CHS to LBA translation and why does the 8GB barrier exist?

CHS to LBA conversion: LBA = (C × heads_per_cylinder + H) × sectors_per_track + S - 1. Traditional values: 1024 cylinders, 16 heads, 63 sectors. This yields 1024 × 16 × 63 = 1,032,192 sectors = 528MB theoretical limit, but BIOS added translation layers.

The 8GB barrier: Standard BIOS uses 12-bit cylinder, 4-bit head, 6-bit sector fields. Max addressable: 4096 cylinders × 16 heads × 63 sectors × 512 bytes = ~2GB. But even 8GB barriers arise when: (1) IDE controllers translate CHS to LBA internally, (2) BIOS translation tables have fixed entries, (3) Operating systems inherit BIOS limitations without proper drivers.

Solution: Use LBA addressing directly, bypass BIOS, use OS-native ATA drivers.

13. What happens during the MBR boot process and how does it locate the OS?

The MBR boot sequence:

  1. Power-on: CPU starts at physical address 0xFFFFFFF0 (reset vector) in ROM
  2. BIOS/UEFI initialization: POST (Power-On Self Test), detect boot device
  3. BIOS reads first 512 bytes (MBR) from boot device to 0x7C00
  4. BIOS validates 0xAA55 signature at offset 510-511
  5. If valid, BIOS jumps to 0x7C00 (transfer control to boot sector code)
  6. Boot sector code: parse partition table, find active (bootable) partition
  7. Load boot loader from first sector of active partition (or stage 2 from known location)
  8. Boot loader (e.g., GRUB) loads kernel from file system, passes control to kernel

For modern UEFI: BIOS is replaced by UEFI firmware which understands GPT and can directly read FAT32 filesystems to load bootloaders from the ESP — no MBR needed.

14. What is the protective MBR in GPT and why does it exist?

The protective MBR occupies the first 512 bytes of a GPT disk, identical to a standard MBR structure. It exists for backward compatibility:

  • Legacy tools (fdisk, older OS installers) see it and recognize the disk as " GPT" (partition type 0xEE) rather than "empty/unallocated"
  • Prevents tools from offering to "initialize" or "convert" the disk, which would destroy the GPT header
  • Protective MBR's partition entry spans the entire disk (or up to 2TB), marking all space as GPT-protected

If a legacy tool writes a new MBR over the protective MBR, it corrupts GPT. GPT-aware tools check for protective MBR but won't use it for partitioning — the actual partition data lives in the GPT header at sector 1.

15. Why does partition alignment matter for SSDs and what is the optimal alignment?

SSD partition alignment: Modern SSDs have erase block sizes (typically 4MB) larger than file system block sizes (4KB). Misaligned partitions cause read-modify-erase penalties:

  1. Write to a 4KB block that spans two erase blocks
  2. SSD must read both erase blocks, modify the 4KB, write both back
  3. This "read-modify-write" degrades performance and increases write amplification

Optimal alignment: 1MB (2048 sectors of 512 bytes) or 4MB (8192 sectors). Partition starting sector divisible by 2048 ensures alignment with SSD erase boundaries and RAID stripe sizes. Most modern tools (gdisk, parted) default to 2048-sector alignment.

Check with: sudo parted /dev/sda align-check opt — should report "1 aligned" for all partitions.

16. How does LVM interact with partition tables and what are the trade-offs?

LVM over partitions vs raw disks: LVM (Logical Volume Manager) sits on top of partitions or raw disks, adding a logical abstraction layer:

  • Partition: Single physical partition (e.g., /dev/sda5) becomes one Physical Volume (PV)
  • Volume Group: Combines multiple PVs into one storage pool
  • Logical Volumes: Virtual partitions carved from VG (e.g., /dev/vg0/home)

Trade-offs: Benefits — snapshot support, dynamic resizing, striping across disks. Drawbacks — added complexity, potential performance overhead from indirection, boot loaders may not understand LVM (use separate /boot partition), recovery more complex.

Typical setup: MBR/GPT partition table → Physical partitions → LVM PVs → VG → LVs → File systems.

17. What is the difference between physical sector size and logical sector size in modern storage?

Logical sector size: What the host system believes the sector size to be (typically 512 bytes for compatibility).

Physical sector size: The actual storage atom on the media (increasingly 4KB native).

Three models:

  • 512-byte native (512n): Old HDDs, some SSDs — both logical and physical are 512 bytes
  • 512-byte emulation (512e): Most modern drives — 4KB physical, 512-byte logical. Must handle unaligned writes correctly to avoid read-modify-write penalties.
  • 4KB native (4Kn): Enterprise drives — both are 4KB. Benefits: more efficient for large sequential I/O, eliminates emulation overhead. Drawback: some OSes and tools assume 512-byte sectors.

Storage capacity calculations depend on which sector size is used as the base unit.

18. How does disk firmware handle bad sectors and what is the role of remapping?

Bad sector remapping: HDD/SSD firmware maintains a "spare area" of extra sectors and a remapping table (G-list for grown defects):

  1. Factory defects: Sectors identified during manufacturing are remapped and recorded in P-list (primary defect list) — these are invisible to host
  2. Reallocated sectors: During operation, failing sectors are remapped — reported as "Reallocated Sectors" in SMART data
  3. Pending sectors: Weak sectors awaiting remapping — count indicates impending failure

When OS writes to LBA and firmware detects ECC error, it: (1) attempts to read with retries, (2) if unrecoverable, remaps to spare sector, (3) updates G-list, (4) returns success to OS. The OS never sees a bad sector — only the remapped address.

Check SMART: smartctl -a /dev/sda | grep -E "Reallocated|Pending_Current|Offline_uncorrectable"

19. How does Secure Boot interact with the partition table and boot process?

Secure Boot is a UEFI feature that validates digital signatures before executing boot code:

  1. UEFI firmware loads from ESP — looks for EFI/BOOT/BOOTX64.EFI (or platform-specific path)
  2. Verifies signature against keys stored in UEFI NVRAM (Platform Key, KEK, db)
  3. If signature valid, firmware transfers control to bootmanager
  4. Bootmanager (e.g., GRUB) must also be signed, loads kernel, verifies kernel signature

Interaction with partition table: Secure Boot doesn't care about MBR vs GPT — it only needs an accessible ESP with signed binaries. However, if MBR is corrupted, the system may not boot to the point where Secure Boot validation occurs. Secure Boot also requires the boot partition to be FAT32 (UEFI spec requirement).

20. How does RAID configuration affect partition table design and disk addressing?

RAID and partition tables: RAID can be implemented at hardware (RAID controller) or software (mdadm):

  • Hardware RAID: The RAID controller presents a "logical disk" to the OS. The OS partitions this logical disk without awareness of underlying physical disks. RAID controller handles striping, mirroring, and reconstruction.
  • Software RAID (Linux md): Multiple partitions on multiple physical disks are combined into a RAID array. Partition alignment must match RAID stripe size (typically 64KB-1MB) for optimal performance.

Addressing considerations: RAID changes the relationship between LBA addressing and physical storage. A single logical LBA may correspond to multiple physical locations (mirrored) or be striped across multiple drives. Partition boundaries should align with stripe boundaries to avoid partial-stripe writes that require read-modify-write cycles.

Further Reading

Topic-Specific Deep Dives:

  • UEFI and GPT: Explore how UEFI firmware interacts with GPT during boot. The EFI System Partition (ESP) contains bootloaders and must be FAT32. Understanding UEFI boot sequence explains why some systems refuse to boot from MBR disks.

  • Zoned Recording: Modern HDDs and some SSDs use zoned recording (shingled magnetic recording on HDDs, zoned namespaces on SSDs). This affects how file systems allocate blocks and why outer zones perform differently than inner zones.

  • 512e vs 4Kn Sector Sizes: The “512e” (512-byte emulation) vs “4Kn” (4KB native) distinction causes confusion in enterprise storage. Understanding why requires examining how modern drives present their geometry to the host system.

  • Disk Partition Alignment: The 1MB alignment requirement (2048 sectors) ensures partitions align with SSD erase block boundaries and RAID stripe sizes. Explore why misalignment causes performance degradation on SSDs.

  • Advanced Format (AF) Drives: Enterprise drives use 4KB native sectors. Study how operating systems handle these drives and why legacy 512-byte assumptions still cause problems in some configurations.

Conclusion

Disk structure determines how storage devices present themselves to the operating system. CHS addressing reflected physical disk geometry, but LBA simplified everything to sequential sector numbers — the translation from logical to physical now happens entirely within the drive firmware. MBR’s 2TB limit and 4-partition constraint pushed the industry toward GPT, which offers near-unlimited partitions, checksums for integrity, and backup headers at the end of the disk.

Partition schemes define the layout, but file systems define the organization within those partitions. The partition table itself is just the starting point — understanding how the OS interprets that table and locates file system structures underneath prepares you for recovery scenarios, capacity planning, and dual-boot configurations.

For deeper learning, explore how UEFI firmware interacts with GPT and the EFI System Partition, how zoned recording affects SSD behavior, and how the distinction between logical and physical sector sizes (512e vs 4Kn) still causes confusion in enterprise environments. The fundamentals of disk geometry underpin everything from storage array configuration to data recovery.

Category

Related Posts

ASLR & Stack Protection

Address Space Layout Randomization, stack canaries, and exploit mitigation techniques

#operating-systems #aslr-stack-protection #computer-science

Assembly Language Basics: Writing Code the CPU Understands

Learn to read and write simple programs in x86 and ARM assembly, understanding registers, instructions, and the art of thinking in low-level operations.

#operating-systems #assembly-language-basics #computer-science

Boolean Logic & Gates

Understanding AND, OR, NOT gates and how they combine into arithmetic logic units — the building blocks of every processor.

#operating-systems #boolean-logic-gates #computer-science