What is a block device?

Probably you will never be able to find a simple definition of this. But in the most general and simplistic way, if you compare a character device to a block device, you can say the character device gives you direct access to the hardware, as in you put in one byte, that byte gets to the hardware (of course it is not as simple as that in this day and age). Whereas, the block device reads from and writes to the device in blocks of different sizes. You can specify the block size but since the communication is a block at a time, there is a buffering time involved.

Think of a block device as a hard disk where you read and write one block of data at a time and, the character device is a serial port. You send one byte of data and other side receives that byte and then the next, and so forth and so on.

Again, it is not a very simple concept to explain. The examples I gave are gross generalizations and can easily be refuted for some particular implementation of each example.


A Block Special File or block device is:

A file that refers to a device. A block special file is normally distinguished from a character special file by providing access to the device in a manner such that the hardware characteristics of the device are not visible.

The precise hardware characteristics are abstracted away by kernel- or driver-level caching. Block devices commonly represent hardware such as disk drives, but that is platform-dependent. FreeBSD doesn't have any block devices at all, for example.

Files, in general, are not devices.

"Block device", as thrown around referring to files, refers to the particular device files in (probably) /dev. It's largely an implementation detail from the user level, with an interface exposed by the driver. Many types of hardware are block-structured internally, but both block and character devices could be used to access them.

Tags:

Block Device