uzu*_*aki 14 hard-drive data-transfer
我一直想知道硬盘驱动器如何找到第一位数据。
当硬盘驱动器旋转时,它读取的内容必须是循环数据流,直到读取头移动到不同的位置。
但是在这样的循环流中,驱动器如何知道第一位和最后一位位于何处,以便它可以以正确的顺序传递数据?
psu*_*usi 18
数据不是作为任意的 1 和 0 流写入的。它是按扇区编写的。每个扇区都有用户数据的有效载荷和一个报头。标头包含纠错码,以及标识扇区开始的特殊同步字段和扇区号,以便驱动器可以知道何时找到扇区的开始以及它是哪个扇区。
Psusi 是正确的(磁盘上的数据是结构化的,计算机的不同部分使用该结构的不同部分)但并没有真正解决您的问题。
驱动器并不真正“知道”任何事情。它具有低级电子设备,可以读取磁盘上的标记(通常在工厂写入,或由驱动器磁头本身写入),从磁盘读取数据块,或将数据块写入磁盘,或判断磁盘上的特定位置磁盘损坏或损坏,或者它应该移动到磁盘上的特定位置。这就是它“知道”的全部内容。读数头不会自己决定移动到其他地方,机器中更高的东西告诉它......
它从磁盘读取它。
磁盘上的数据不仅是结构化的(如 @psusi 所说),而且是编码的。编码确保记录的数据不会与扇区标题中的位置标记混淆,因此可以读取循环流,直到找到目标位置标记。
As I understand it, modern hard drives don't quite do that; they read the entire circle into a buffer, keeping track of where each sector is, and use the buffers to send back requested data.
UPDATE:
The magnetic media is a material which has a magnetic field with two key properties: 1) it never changes on its own, and 2) the recording device can change the orientation of the field at any point on the surface. When reading the media, the sensor detects where the field is oriented toward the sensor and where the field is oriented away from the sensor. As the sensor moves across the surface it detects the timings of these polarity transitions; the first layer of decoding is translating these timings into bit values. Due to physically necessary uncertainties in this process, the encoding must not require long stretches of the same polarity; that is, it must be a Run-length limited coding (RLL).
The particulars of hard drive designs are generally trade secrets, but there are essentially two ways to ensure that sector markers never appear in sector content:
设计一个允许特殊值的 RLL,这些值永远不会因编码内容数据而产生。这些特殊值不仅可以用于标记扇区边界,还可以用于纠错或任何其他次要目的。
使用第二层编码,确保标记值仅出现在标记处。这有点像URL 编码,允许特殊字符“隐藏”在 URL 中,但有一个额外的约束,相当于限制可以添加的字符数量,所以它最终更像是base64 编码。
因此,读取头在表面上移动,检测磁极性变化,这些变化的时序用于确定相应的位值序列(可能包括一些不代表存储数据的异常值),并且该序列用于确定正在读取哪些扇区以及这些扇区的内容。当扇区的内容被确定时,数据可以被存储在固态缓冲器中和/或存储在RAM缓冲器中和/或被发送回以满足请求。