A block device is a device that the operating system accesses in fixed-size blocks of data, with random access to any block by its address, and usually through a kernel buffer or cache. Hard disk drives, solid-state drives, USB flash drives, SD cards and virtual disks are all presented as block devices. In the study of drivers & devices, the block device is one of the two classic device classes, alongside the character device, which transfers a stream of bytes without addressable positions.
The abstraction matters because file systems, partitions and volume managers are built on top of it. A file system never talks directly to flash cells or magnetic platters; it asks the block layer to read or write numbered blocks, and the driver translates those requests into commands for the actual hardware.
How a block device works inside the kernel
A block device exposes storage as a linear array of logical blocks, each identified by a logical block address (LBA). Upper layers submit requests that name a starting block, a length and a direction (read or write). The kernel’s block layer collects these requests, may merge adjacent ones, orders them through an I/O scheduler and passes them to the device driver.
The driver converts each request into the device’s own command set, such as SATA commands for AHCI controllers, NVMe submission queue entries or SCSI commands, and typically uses direct memory access to move data between RAM and the device without CPU copying. Completion is signaled by an interrupt or detected by polling, after which the block layer wakes the waiting process or completes the asynchronous operation.
The table below shows the main components on the path from a file system to the hardware.
| Layer | Role | Example |
|---|---|---|
| File system | Maps files to block addresses | ext4, NTFS, APFS |
| Page cache or buffer cache | Holds recently used blocks in RAM | Kernel caching layer |
| Block layer | Queues, merges and schedules requests | Linux blk-mq, Windows storage stack |
| Device driver | Translates requests into device commands | NVMe, AHCI, virtio-blk drivers |
| Hardware | Stores data persistently | SSD, HDD, flash card |
Block size, sectors and alignment
Several sizes coexist on a block device, and confusing them is a frequent cause of poor performance. The logical sector size is the smallest unit the device accepts in a command, traditionally 512 bytes. The physical sector size is the unit the hardware writes internally, commonly 4,096 bytes on modern drives. The file system block size is chosen at format time, usually 4 KiB.
When partitions or file system blocks are misaligned with physical sectors, a single logical write can force the drive to perform a read-modify-write cycle across two physical sectors. Modern partitioning tools align partitions to 1 MiB boundaries by default, which avoids this problem on both hard drives and flash media.
| Unit | Typical value | Defined by |
|---|---|---|
| Logical sector | 512 bytes or 4,096 bytes | Device interface |
| Physical sector | 4,096 bytes | Drive hardware |
| File system block | 4 KiB (range 1 to 64 KiB) | Format options |
| Flash erase block | Hundreds of KiB to several MiB | NAND flash geometry |
Block devices compared with character devices
The distinction between block and character devices comes from Unix and still shapes device files and driver interfaces. A character device delivers or accepts a sequential stream of bytes, as keyboards, serial ports and terminals do, and generally cannot seek to an arbitrary position. A block device supports seeking, buffering and partitioning, which makes it suitable for hosting a file system.
| Property | Block device | Character device |
|---|---|---|
| Access pattern | Random access by block address | Sequential byte stream |
| Transfer unit | Fixed-size blocks | Individual bytes or variable records |
| Kernel caching | Usually buffered through a cache | Usually unbuffered |
| Can host a file system | Yes | No |
| Typical examples | SSD, HDD, loop device | Serial port, terminal, mouse |
The boundary is not absolute. Linux historically offered raw character interfaces to disks, and today applications such as databases can open block devices with direct I/O to bypass the page cache. FreeBSD dropped the separate block device files altogether and exposes disks only as character devices, while the kernel still treats them as block storage internally.
How operating systems name and expose block devices
Each operating system presents block devices through its own naming scheme and device file conventions. Recognizing these names is essential when partitioning disks, writing images or mounting volumes, because selecting the wrong device can destroy data in seconds.
| Operating system | Typical device names | Notes |
|---|---|---|
| Linux | /dev/sda, /dev/nvme0n1, /dev/mmcblk0 | Partitions add a number or p suffix |
| macOS | /dev/disk0, /dev/rdisk0 | The r prefix gives unbuffered access |
| Windows | \\.\PhysicalDrive0, volume GUID paths | Drive letters map to volumes |
| FreeBSD | /dev/ada0, /dev/nvd0 | Exposed only as character device nodes |
Block devices are also created entirely in software. Loop devices turn a file into a block device, RAM disks use memory, device mapper targets implement encryption or logical volumes, and virtual machines see virtio-blk or emulated SCSI disks backed by image files on the host.
Performance factors and common mistakes
Block device performance depends on the hardware, the queue depth and the scheduling policy. NVMe drives support thousands of parallel queues, so the kernel usually applies minimal scheduling to them, while rotational disks benefit from schedulers that reorder requests to reduce seek time.
- Writing to the wrong device: tools that write raw images will overwrite any block device they are given, with no file system safeguards.
- Ignoring write caching: a completed write may sit in the drive cache; flush or barrier commands are required for durability.
- Misaligned partitions: legacy layouts starting at sector 63 cause extra internal writes on 4 KiB drives.
- Assuming sequential speed everywhere: small random I/O on hard drives can be hundreds of times slower than sequential transfers.
In plain words
A block device is any storage the computer can treat like a huge notebook with numbered pages. The system can open any page directly, read it or rewrite it, without going through all the pages before it. Disks, SSDs and memory cards all work this way.
The main point is that this simple numbered-page view lets the computer build folders and files on top of very different kinds of hardware, all in the same way.
A real-world example
A Linux administrator adds a new 2 TB NVMe drive to a database server. The kernel detects it and creates the block device /dev/nvme1n1. The administrator checks with lsblk that the size and model match, creates a single GPT partition aligned at 1 MiB, and formats it with ext4 using 4 KiB blocks.
Because the database performs its own caching, it opens its data files with direct I/O, so requests go straight through the block layer to the NVMe driver. Benchmarks show about 400,000 random 4 KiB reads per second at a queue depth of 64, and the earlier risk of overwriting the system disk was avoided by verifying the device name before formatting.