19

This question already has an answer here:

I know many examples of block devices (HDD's, SSD's, files, ...), but I haven't heard a simple definition of it. Especially since files are apparently included in the definition I feel a bit confused...

marked as duplicate by Jeff Schaller, mdpc, Scott, Michael Homer, cuonglm Feb 2 '16 at 2:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

10

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.

19

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.