[Reprinted] Storage principle and internal structure of hard disk

I originally wanted to write a topic on file systems, but I found that the internal structure and storage principles of hard disks were still relatively vague. Because I didn't understand "a little" the storage principles of hard disks, my understanding of file systems always felt vague and unreliable. After collecting and sorting out the information, this article came out. To borrow a sentence from brother Bean_lee: achievements and glory belong to the predecessors.
 

First, let's take a look at the history of hard drives:

 

  • On September 13, 1956, IBM's IBM 350 RAMAC (Random Access Method of Accounting and Control) was the prototype of a modern hard drive. The entire hard drive required 50 platters with a diameter of 24 inches coated with magnetic pulp, which is equivalent to two. The volume of the refrigerator, but its storage capacity is only 5MB.
  • In 1971, IBM began producing hard drives using a technology called Merlin, which supposedly enabled the hard drive heads to better index on the platters.
  • In 1973, the IBM 3340 came out, and the mainstream adopted red. This big guy stored 1.7MB of data per square inch, a record at the time. Many companies share these systems, renting it for time and storage space when needed. The lease value was $7.81 per megabyte, which was 38% more expensive than gasoline at the time. It has the nickname "Winchester", which is now known as the "Winchester Architecture". From its two 30MB storage units, it happened to be the caliber and reload of the famous "Winchester Rifle" at the time. So far, the basic structure of the hard disk has been established.
  • In 1979, IBM invented the Thin Film magnetic head, which made the data positioning of the hard disk more accurate, thus greatly increasing the density of the hard disk.
  • In 1980, the company founded by two former IBM employees developed the 5.25-inch 5MB hard drive, the first product for the desktop, and the company was Seagate.
  • In 1982, Hitachi released the world's first hard drive with a capacity of more than 1GB. This is the H-8598 hard drive with a capacity of 1.2GB. This hard drive has 10 14-inch platters and two read-write heads.
  • In the late 1980s, IBM introduced MR (Magneto Resistive) technology, which greatly improved the sensitivity of the magnetic head and increased the storage density of the disk by dozens of times compared to the previous 20Mbpsi (bit/square inch). Ascension laid the foundation. In 1991, IBM introduced the first 3.5-inch 1GB hard drive using this technology.
  • From 1970 to 1991, the storage density of hard disks increased at an annual rate of 25% to 30%; from 1991 to 60% to 80%; so far, the speed has increased to 100% or even 200%. The astonishing speed increase since 1997 is due to IBM's GMR (Giant Magneto Resistive) technology, which further improves the sensitivity of the magnetic head, thereby increasing the storage density.
  • In 1993, Conner Peripherals launched the CP30344 hard drive with a capacity of 340MB.
  • In 1995, in order to cooperate with Intel's LX chipset, Quantum and Intel jointly released the UDMA 33 interface - the EIDE standard, which increased the data transfer rate of the original interface from 16.6MB/s to 33MB/s. In the same year, Seagate developed a fluid bearing (FDB, Fluid Dynamic Bearing) motor. The so-called FDB refers to the introduction of the technology on the gyroscope into the hard disk production, replacing the metal bearing with an oil film with a thickness equivalent to one-tenth of the diameter of a hair, reducing the noise and heat generation of the hard disk.
  • In 1996, Seagate acquired Conner Peripherals
  • In February 1998, the UDMA 66 specification was introduced.
  • In October 2000, Maxtor acquired Quantum.
  • In January 2003, Hitachi announced the completion of the $2.05 billion acquisition of IBM's hard drive division and established Hitachi Global Storage Technologies (Hitachi GST).
  • In 2005, both Hitachi and Seagate announced that they would start to use disk vertical writing technology (perpendicular recording), which is to change the direction of the magnetic field parallel to the disk to vertical (90 degrees), making more full use of storage space. .
  • On December 21, 2005, Seagate announced the acquisition of Maxtor.
  • In January 2007, Hitachi Global Storage Technology announced that it would release the world's first 1Terabyte hard drive, more than a year later than the original scheduled time. The hard drive sells for $399, and you can buy an average of 27.5MB of hard drive space per cent.
  • In March 2011, Western Digital acquired Hitachi Global Storage Technology for $4.3 billion.
  • In April 2011, Seagate announced a strengthened strategic partnership with Samsung.

 

 
    It has been 56 years since the advent of hard disks. There have been major innovations and improvements in capacity, volume and production process compared to the previous ones, but the "Wen's" structure has always been maintained (except for solid-state drives, which are not what we have today). main character). The encapsulated hard disk generally looks like this to us:
 
    back:
 
    Open the back cover:
 

    The hard disk is mainly composed of the disk body, the control circuit board and the interface components. The disk body is a sealed cavity that encapsulates multiple disks; the control circuit includes units such as hard disk BIOS, main control chip and hard disk cache; the interface components include power supply, data interface master-slave jumpers, etc.

 

    The platters of hard disks are generally made of alloy materials, most of which are aluminum alloys (IBM has developed platters made of glass material, it seems that some manufacturers also produce platters made of glass material, but they are rare), and the disk surface is coated with magnetic materials, with a thickness of Generally about 0.5mm. Some hard drives hold only one platter, while others have multiple. The hard disk platter is installed on the shaft of the spindle motor and rotates at high speed under the drive of the spindle motor. The capacity of each platter is called the single-disc capacity, and the total capacity of a hard disk is the sum of the capacities of all platters. Early hard disks had more platters due to the low capacity of a single disk. Modern hard disks generally have only a few platters. The recording density on the platter is very high, and the platter will rotate at a high speed when it is working. In order to ensure the stability of its work and the long-term preservation of data, the hard disk is sealed inside the hard disk. Do not disassemble the hard disk by yourself. In ordinary environments, small impurities such as dust, fingerprints, and hair strands in the air will cause permanent damage to the hard disk. A hard drive that has been dismantled into eight pieces is as follows:

 

 

    Next, let's take a look at the concepts of hard disk surface, cylinder, track and sector.

 

    disk

    A hard disk generally has one or more platters, and each platter can have two sides (Side), that is, the front side of the first platter is called side 0, and the reverse side is called side 1; the front side of the second platter is called side 1. It's called 2-sided, the opposite is called 3-sided...and so on. Each disk surface corresponds to a head for reading and writing data. The head on the front of the first platter is called head 0, the back is called head 1; the head on the front of the second platter is called head 2, the back is called head 3, and so on. The number of disks and heads are equal.

 

 

 

 

    A single-sided platter requires one head, and a double-sided platter requires two heads. The hard drive uses a high-precision, light-weight head drive and positioning system. This system can make the magnetic head move quickly on the disk surface. When reading and writing the hard disk, the magnetic head is suspended on the disk surface by the aerodynamic effect caused by the high-speed rotation of the disk, and the distance from the disk surface is less than 1 micrometer (about 100% of the diameter of a hair). 1), it can be precisely positioned on the track specified by the computer instruction in a very short time.

    In the early days, due to the limitation of the positioning system, the head drive arm could only move between the inner and outer tracks of the platter. Therefore, the head is always on the platter whether it is turned on or off. The difference is that the magnetic head stays in the start-stop area of ​​the platter when it is turned off, and the magnetic head "flyes" above the platter when it is turned on.

 

    track

    Each disk surface of each platter is divided into multiple narrow concentric rings, and data is stored on such concentric rings. We call such rings a track, and each disk surface can be divided into multiple track. When the disk is turned off, the magnetic head stays in the Landing Zone of the hard disk. This landing zone was previously located in the area closest to the disk center and does not store any data. In the later hard disk process, some hard disk manufacturers moved this area to the outside of the platter, as shown below:

 

 

 

    In the outermost circle of each disk surface, the farthest place from the disk center is the "0" track, which increases to track 1, track 2, and so on in the direction of the center of the disk. The storage of hard disk data starts from the outermost circle.

 

    sector

    根据硬盘规格的不同,磁道数可以从几百到成千上万不等。每个磁道上可以存储数KB的数据,但计算机并不需要一次读写这么多数据。在这一这基础上,又把每个磁道划分成若干弧段,每段称为一个扇区(Sector)。扇区是硬盘上存储的物理单位,每个扇区可存储128×2N次方(N=0,1,2,3)字节的数据。从DOS时代起,每扇区是128×22=512字节,现在已经成了业界不成文的规定,也没有哪个硬盘厂商试图去改变这种约定。也就是说即使计算机只需要硬盘上存储的某个字节,也须一次把这个字节所在的扇区中的全部512字节读入内存,再选择所需的那个字节。扇区的编号是从1开始,而不是0,这一点需要注意。另外,硬盘在划分扇区时,和软盘是有一定区别的。软盘的一个磁道中,扇区号一般依次编排,如1号,2号,3号...以此类推。但在硬盘磁道中,扇区号是按照某个间隔跳跃着编排。比如,2号扇区并不是1号扇区后的按顺序的第一个而是第八个,3号扇区又是2号扇区后的按顺序的第八个,依此类推,这个“八”称为交叉因子。

    这个交叉因子的来历有必要详述一下,我们知道,数据读取经常需要按顺序读取一系列相邻的扇区(逻辑数据相邻)。如对磁道扇区按物理顺序进行编号,很有可能出现当磁头读取完第一个扇区后,由于盘片转速过快来不及读取下一个扇区,(要知道物理相邻扇区位置距离是极小的),必须等待转完一圈,这极大浪费了时间。所以就用交叉来解决这个问题。增加了交叉因子后的扇区编号一般是下面这个样子:

 

 

 

    柱面

    柱面其实是我们抽象出来的一个逻辑概念,前面说过,离盘心最远的磁道为0磁道,依此往里为1磁道,2磁道,3磁道....,不同面上相同磁道编号则组成了一个圆柱面,即所称的柱面(Cylinder)。这里要注意,硬盘数据的读写是按柱面进行,即磁头读写数据时首先在同一柱面内从0磁头开始进行操作,依次向下在同一柱面的不同盘面(即磁头上)进行操作,只有在同一柱面所有的磁头全部读写完毕后磁头才转移到下一柱面,因为选取磁头只需通过电子切换即可,而选取柱面则必须通过机械切换。电子切换比从在机械上磁头向邻近磁道移动快得多。因此,数据的读写按柱面进行,而不按盘面进行。 读写数据都是按照这种方式进行,尽可能提高了硬盘读写效率。

 

    

    将物理相邻的若干个扇区称为了一个簇。操作系统读写磁盘的基本单位是扇区,而文件系统的基本单位是簇(Cluster)。在Windows下,随便找个几字节的文件,在其上面点击鼠标右键选择属性,看看实际大小与占用空间两项内容,如大小:15 字节 (15 字节), 占用空间:4.00 KB (4,096 字节)。这里的占用空间就是你机器分区的簇大小,因为再小的文件都会占用空间,逻辑基本单位是4K,所以都会占用4K。 簇一般有这几类大小 4K,8K,16K,32K,64K等。簇越大存储性能越好,但空间浪费严重。簇越小性能相对越低,但空间利用率高。NTFS格式的文件系统簇的大小为4K。

 

 

 

 

 

    硬盘读写数据的过程

    现代硬盘寻道都是采用CHS(Cylinder Head Sector)的方式,硬盘读取数据时,读写磁头沿径向移动,移到要读取的扇区所在磁道的上方,这段时间称为寻道时间(seek time)。因读写磁头的起始位置与目标位置之间的距离不同,寻道时间也不同。目前硬盘一般为2到30毫秒,平均约为9毫秒。磁头到达指定磁道后,然后通过盘片的旋转,使得要读取的扇区转到读写磁头的下方,这段时间称为旋转延迟时间(rotational latencytime)。

 

    一个7200(转/每分钟)的硬盘,每旋转一周所需时间为60×1000÷7200=8.33毫秒,则平均旋转延迟时间为8.33÷2=4.17毫秒(平均情况下,需要旋转半圈)。平均寻道时间和平均选装延迟称为平均存取时间。

 

    所以,最后看一下硬盘的容量计算公式:

    硬盘容量=盘面数×柱面数×扇区数×512字节

 

 

    MBR中,它是存在于硬盘的0柱面,0磁头,1扇区里,占512字节的空间。这512字节里包含了主引导程序Bootloader和磁盘分区表DPT。其中Bootloader占446字节,分区表占64字节,一个分区要占用16字节,64字节的分区表只能被划分4个分区,这也就是目前我们的硬盘最多只能支持4个分区记录的原因。

 

    即,如果你将硬盘分成4个主分区的话,必须确保所有的磁盘空间都被使用了(这不是废话么),一般情况下我们都是划分一个主分区加一个扩展分区,然后在扩展分区里再继续划分逻辑分区。当然,逻辑分区表也需要分区表,它是存在于扩展分区的第一个扇区里,所以逻辑分区的个数最多也只能有512/16=32个,并不是想分多少个逻辑分区都可以。

    注意,我们所说的扩展分区也是要占用分区表项的。例如,如果我们的硬盘只划分一个主分区和一个逻辑分区,此时的分区表的排列如下:

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          19      152586   83  Linux

/dev/sda2              20        2569    20482875   83  Extended

/dev/sda5            2570        19457     4128705   82  Linux

    主分区为1号分区,扩展分区占用了2号分区,3和4号扩展分区被预留了下来,逻辑分区从5开始编号依次递增,这里我们只划分了一个逻辑分区。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324692647&siteId=291194637