Search code examples
iooperating-systemposixdisknt

Does disk IO correspond directly to its physical sector location?


I've been playing around with disk IO on flash drives, HDDs, and SSDs by opening /dev/sd* paths in Linux the way I would any other file.

I understand that the memory controller on the disk can hide true block order (via a mapping) from the OS.

This boils down to these questions:

  1. Are the blocks in /dev/sd* in the order perceived by the OS, or in the order as perceived by the disk's memory controller?

  2. Is the order of blocks in /dev/sd* subjective between POSIX OSes?

  3. Can these properties change if done on an NT or Cygwin system?

  4. Is this property different among Flash, HDD, and SSD?

  5. Can a write occur to a specific index in an opened /dev/sd* path, or is this determined by the memory controller?

Thanks in advance!


Solution

  • If you use the device nodes for entire disks (/dev/sda, /dev/sdb, and so on), then the file offsets for the block device correspond to logical block addresses and will be portable across systems (assuming that the disk sector size is supported). This is independent of the storage technology.

    However, the names of the device nodes are different from system to system.

    If you use sub-devices (partitions), this is not necessarily the case because interpretation of and support for partition tables varies considerably.