Loading learning content...
Every time you save a file, install an application, or boot your operating system, you're relying on block devices—the workhorses of persistent storage in modern computing. Block devices form the fundamental abstraction through which operating systems interact with storage hardware, from mechanical hard drives spinning at 7,200 RPM to NVMe SSDs delivering millions of I/O operations per second.
Understanding block devices isn't merely academic—it's essential knowledge for any engineer who designs systems that store data, optimizes database performance, or troubleshoots I/O bottlenecks in production environments.
By the end of this page, you will understand what defines a block device, why the block abstraction is fundamental to storage systems, how block addressing works from logical to physical mapping, and how operating systems leverage block device characteristics for optimal performance. You'll gain insights that apply whether you're working with traditional HDDs, modern SSDs, or distributed storage systems.
A block device is an I/O device that stores and retrieves data in fixed-size chunks called blocks (also known as sectors at the hardware level). Unlike character devices that handle data as continuous streams of bytes, block devices provide random access—any block can be read or written independently, regardless of the physical location of previously accessed data.
The defining characteristics of block devices:
While 'block' and 'sector' are often used interchangeably, there's a subtle distinction. Sector typically refers to the hardware's native unit (the smallest addressable unit on the physical device), while block refers to the logical unit used by the file system or operating system. The OS block size is often a multiple of the hardware sector size—for example, a 4KB file system block spanning eight 512-byte sectors.
Block devices present a deceptively simple interface to the operating system: an array of numbered blocks. However, the internal architecture that supports this abstraction is remarkably sophisticated.
The logical view vs. physical reality:
To the operating system, a block device appears as a linear array of blocks, numbered from 0 to N-1, where N is the device capacity divided by the block size. This logical view conceals enormous physical complexity:
| Logical View (OS Perspective) | Physical Reality (Hardware) |
|---|---|
| Linear array of blocks | Platters, tracks, cylinders (HDD) or flash cells, pages, blocks (SSD) |
| Uniform access time for any block | Wildly varying access times based on physical location and device state |
| Blocks simply exist and are always ready | Complex wear leveling, garbage collection, bad block management |
| Sequential block numbers | Intricate physical-to-logical mapping tables maintained by device firmware |
| Atomic block operations | Multi-step internal processes with journaling and error correction |
Internal components of modern block devices:
Device Controller — The onboard processor that mediates between the host interface (SATA, NVMe, etc.) and the storage medium. Controllers handle command queuing, error correction, and logical-to-physical address translation.
Internal Cache/Buffer — DRAM-based cache (typically 64MB-256MB for HDDs, 1GB+ for enterprise SSDs) that buffers data for read caching and write coalescing.
Storage Medium — The actual data storage: magnetic platters for HDDs, NAND flash cells for SSDs, with vastly different performance characteristics.
Firmware — Sophisticated software running on the device controller, implementing the device's behavior, optimization algorithms, and protocol compliance.
SSDs include a Flash Translation Layer (FTL)—a critical firmware component that makes flash storage behave like a traditional block device. The FTL handles wear leveling (distributing writes across all flash cells), garbage collection (reclaiming space from partially-invalid pages), and bad block management. Understanding the FTL is crucial for optimizing SSD performance in database and storage system design.
Block addressing is the mechanism by which the operating system identifies specific blocks on a storage device. The evolution of addressing schemes reflects the growth in storage capacity and the need for efficient access methods.
Historical: Cylinder-Head-Sector (CHS) Addressing
Early hard drives used CHS addressing, where each block was identified by three coordinates:
CHS addressing had severe limitations: the original AT BIOS specification allowed only 1,024 cylinders × 16 heads × 63 sectors = 504 MB. Even with extensions, CHS hit practical limits around 8.4 GB and was fundamentally tied to a specific physical geometry that SSDs don't have.
Modern: Logical Block Addressing (LBA)
LBA replaced CHS with a simpler abstraction: blocks are numbered sequentially starting from 0. The device internally translates LBAs to physical locations, hiding the geometry from the operating system.
LBA specifications:
| LBA Standard | Address Bits | Maximum Capacity (512-byte sectors) | Maximum Capacity (4KB sectors) |
|---|---|---|---|
| LBA28 | 28 bits | 128 GB | 1 TB |
| LBA48 | 48 bits | 128 PB | 1 EB |
| NVMe (64-bit) | 64 bits | 8 ZB | 64 ZB |
Advanced Format: The 4K Sector Transition
For decades, the standard sector size was 512 bytes, a legacy from early hard drive designs. However, as areal density increased, 512-byte sectors became inefficient:
The industry transition to Advanced Format (AF) introduced:
This transition has significant implications for partition alignment and performance—misaligned writes can cause read-modify-write overhead.
On 512e drives, if a partition or file system starts at a sector not divisible by 8, every 4KB file system block spans two physical sectors. This forces the drive to perform read-modify-write operations for every write, potentially halving write performance. Modern partitioning tools (GPT, GUID Partition Table) align partitions to 1MB boundaries, ensuring optimal alignment for all current sector sizes.
Block devices support a well-defined set of operations that form the interface between the operating system and storage hardware. Understanding these operations is fundamental to storage system design and performance optimization.
Primary Block Operations:
The Block I/O Path:
A block I/O request traverses multiple layers from application to storage:
Application → System Call → VFS Layer → File System → Block Layer → I/O Scheduler → Device Driver → Host Bus Adapter → Storage Device
Each layer adds functionality:
The block device abstraction encompasses a diverse range of storage technologies, each with distinct performance characteristics, failure modes, and optimal use cases. Understanding these differences is crucial for system design.
Hard Disk Drives (HDDs):
HDDs store data on rotating magnetic platters, accessed by moving read/write heads. Their characteristics:
| Parameter | Typical Value | Performance Impact |
|---|---|---|
| Seek Time | 4-10 ms | Dominates random access latency; moving heads is mechanical |
| Rotational Latency | 2-6 ms (avg) | Half rotation on average; 7,200 RPM = 4.17ms avg |
| Transfer Rate | 100-250 MB/s | Sequential throughput; limited by platter density and RPM |
| IOPS (Random) | 75-200 | Severely limited by mechanical latency |
| IOPS (Sequential) | Thousands | Limited by transfer rate, not seek/rotation |
Solid State Drives (SSDs):
SSDs use NAND flash memory with no moving parts, offering dramatically different performance profiles:
| Parameter | Typical Value (SATA SSD) | Typical Value (NVMe SSD) |
|---|---|---|
| Read Latency | 50-100 μs | 10-20 μs |
| Write Latency | 100-500 μs | 20-50 μs |
| Sequential Read | 500-560 MB/s | 3,000-7,000 MB/s |
| Sequential Write | 400-530 MB/s | 2,000-5,000 MB/s |
| Random Read IOPS | 70,000-100,000 | 500,000-1,000,000+ |
| Random Write IOPS | 50,000-90,000 | 200,000-800,000 |
Other Block Device Types:
Device selection should match workload characteristics. HDDs excel at sequential, archival workloads (cost per GB). SATA SSDs suit boot drives and general-purpose servers. NVMe SSDs are essential for databases, virtualization, and latency-sensitive applications. Understanding your I/O pattern (random vs. sequential, read vs. write ratio, I/O size) guides optimal device selection.
Operating systems provide a sophisticated subsystem for managing block devices, abstracting hardware differences while enabling advanced features. Let's examine how major operating systems represent and manage block devices.
Linux Block Device Subsystem:
Linux represents block devices as special files in /dev:
12345678910111213141516171819202122232425
# List block devices with detailslsblk -o NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,ROTA,MODEL # Output example:# NAME TYPE SIZE FSTYPE MOUNTPOINT ROTA MODEL# sda disk 1.8T ext4 1 WDC WD2003FZEX# ├─sda1 part 512M vfat /boot/efi 1 # ├─sda2 part 1G ext4 /boot 1 # └─sda3 part 1.8T ext4 / 1 # nvme0n1 disk 931.5G 0 Samsung SSD 970# └─nvme0n1p1 part 931.5G xfs /data 0 # ROTA=1 means rotational (HDD), ROTA=0 means non-rotational (SSD) # View device statisticscat /proc/diskstats | grep -E "sda|nvme0n1" # Check I/O scheduler for a devicecat /sys/block/sda/queue/scheduler# Output: [mq-deadline] kyber bfq none # View block device parametersblockdev --report /dev/sda# Output: RO RA SSZ BSZ StartSec Size Device# 0 256 512 4096 0 ... /dev/sdaLinux Block Device Naming Conventions:
Windows Block Device Management:
Windows uses a different model, assigning drive letters and managing disks through the Storage Subsystem:
1234567891011121314151617181920
# List physical disksGet-PhysicalDisk | Select-Object DeviceId, FriendlyName, MediaType, Size, HealthStatus # Output:# DeviceId FriendlyName MediaType Size HealthStatus# -------- ------------ --------- ---- ------------# 0 WDC WD2003FZEX-00RLFA0 HDD 2000398934016 Healthy# 1 Samsung SSD 970 EVO Plus SSD 1000204886016 Healthy # Get disk I/O statisticsGet-Counter '\PhysicalDisk(*)\Disk Reads/sec', '\PhysicalDisk(*)\Disk Writes/sec' # Check disk propertiesGet-Disk | Select-Object Number, FriendlyName, PartitionStyle, Size # Using diskpart for low-level operationsdiskpartDISKPART> list diskDISKPART> select disk 0DISKPART> detail diskIn Linux, block devices are identified by major and minor numbers. The major number identifies the device driver (e.g., 8 for sd* devices), while the minor number identifies the specific device instance. For example, /dev/sda (major 8, minor 0), /dev/sda1 (major 8, minor 1). You can see these with 'ls -la /dev/sda*'. This numbering scheme enables the kernel to route I/O requests to the correct driver.
Optimizing block device performance requires understanding multiple interacting factors. The gap between theoretical maximum performance and real-world throughput is often substantial, and closing this gap demands systematic analysis.
Key Performance Metrics:
The I/O Scheduler Impact:
The operating system's I/O scheduler reorders and merges block requests before sending them to the device. Different schedulers optimize for different goals:
| Scheduler | Best For | Mechanism | Latency | Throughput |
|---|---|---|---|---|
| none | NVMe SSDs | Direct submission, no reordering | Lowest | Highest for fast devices |
| mq-deadline | SSDs, latency-sensitive | Per-request deadlines, prevents starvation | Low, bounded | Good |
| bfq | Desktop, interactive | Fair bandwidth allocation, I/O priority | Fair | Variable |
| kyber | Fast SSDs | Lightweight token-based | Low | High |
SSDs suffer from write amplification: the ratio of data actually written to flash versus data sent by the host. Due to the need to erase blocks before writing (and blocks being larger than pages), writing 4KB might cause 256KB or more of actual flash writes. This increases wear and reduces write performance. TRIM support, over-provisioning, and sequential write patterns all help minimize write amplification.
Block devices provide the fundamental abstraction that makes modern storage systems possible. By presenting diverse hardware as simple arrays of numbered blocks, they enable file systems, databases, and applications to work with storage without concerning themselves with physical details.
Key Takeaways:
What's next:
Block devices are just one category in the I/O device taxonomy. The next page explores character devices—devices that handle data as continuous byte streams rather than fixed blocks. You'll discover how keyboards, mice, serial ports, and other stream-oriented hardware present fundamentally different challenges and interface requirements.
You now have a deep understanding of block devices—their defining characteristics, architecture, addressing mechanisms, and performance considerations. This foundation is essential for understanding file systems, storage management, and I/O optimization throughout your systems engineering journey.