I wanted to write a file system topic and found that the internal architecture and Storage Principles of the hard disk are still vague, because I don't know the storage principle of a "one point" hard disk, I always feel the image is not practical. After collecting and sorting out the materials, this article was published. Borrow a word from bean_lee: Achievements and honors are attributed to the predecessors.
First, let's take a look at the development history of hard disks:
- In September 13, 1956, IBM's 350 ramac (random access method of accounting and control) was the prototype of a modern hard disk, and the entire hard disk required 50 disks with 24 inch in diameter coated with magnetic paste, it is equivalent to the size of two refrigerators, but its storage capacity is only 5 MB.
- In 1971, IBM began using a technology called Merlin to produce hard disks, which is said to make hard disk headers better indexed on disk disks.
- In 1973, IBM 3340 was launched and the mainstream adopted red. This big guy stored MB of data per square inch, which had already set a record. Many companies share these systems and lease them by time and storage space as needed. The rental value is USD 7.81 per megabits, Which is 38% more expensive than the current price of gasoline. It has the nickname "Winchester", which we are now familiar ". It comes from its two 30 mb storage units, which are exactly the caliber and fill volume of the famous "Winchester rifle. So far, the basic architecture of the hard disk has been established.
- In 1979, IBM invented the thin film head to make the data location of the hard disk more accurate, which greatly increased the hard disk density.
- In 1980, two companies founded by former IBM employees developed a 5.25 Inch-inch 5 MB hard drive, the first desktop-facing product, and the company is Seagate.
- In 1982, Hitachi released the world's first hard drive with a capacity of more than 1 GB. This is the capacity of 1 2 GB H-8598 hard disk. This hard disk has 10 14 inch disks and two read/write heads.
- At the end of the 1980 s, IBM introduced the MR (Magneto resistive reluctance) technology to greatly improve the head sensitivity, making the disk storage density 20 mbpsi (bit/per square inch) higher than the previous one) increased by dozens of times, this technology laid the foundation for a huge increase in hard disk capacity. In 1991, IBM applied the technology to launch the first 3.5 inch GB hard drive.
- From 1970 to 1991, the storage density of Hard Disk disks is 25% ~ 30% growth rate; from 1991 to 60% ~ 80%; so far, the speed has increased to 100% or even 200%. Thanks to IBM's GMR (Giant Magneto resistive) technology, the amazing speed increase since 1997 has further increased the head sensitivity and storage density.
- In 1993, Conner peripherals released cp30344 with a hard disk capacity of 340 MB.
- In 1995, in concert with Intel's lx chipset, kunteng and Intel jointly released the udma 33 interface-Eide standard to increase the original interface data transmission rate from 16.6 MB/s to 33 Mb/s. In the same year, Seagate developed a liquid bearing (FDB, fluid dynamic bearing) motor. The so-called FDB refers to introducing the technology on gyroscope to hard disk production, replacing the metal bearing with an oil film equivalent to a tenth of the hair diameter, reducing the hard disk noise and heat.
- In 1996, Seagate acquired Conner peripherals)
- In February 1998, The udma 66 specification was available.
- In October 2000, maxtor acquired kunteng.
- In January 2003, Hitachi announced the completion of its $2.05 billion acquisition of the IBM hard drive business unit and the establishment of Hitachi global storage technologies (Hitachi global storagetechnologies, Hitachi GST ).
- In 2005, Hitachi central storage and Seagate both announced that they would begin to use a large number of disk vertical writes (perpendicular recording), which would change the magnetic field direction parallel to the vertical (90 degrees) of the disk ), more fully utilized storage space.
- On July 6, December 21, 2005, Seagate announced the acquisition of maxtor ).
- On July 6, January 2007, Hitachi global Storage Technology announced that it would release the world's first 1 terabyte hard drive, more than a year later than originally scheduled. The price of a hard disk is USD 399, and the disk space is 27.5mb on average per cent.
- In March 2011, Western data acquired Hitachi global Storage Technology for $4.3 billion.
- On June 23, April 2011, Seagate announced a strengthened strategic partnership with Samsung.
It has been 56 years since the advent of hard disks, and significant innovations and improvements have been made in both capacity, volume, and production processes, however, we have always maintained the "Wen Shi" Architecture (except SSD, which is not our main character today ). The encapsulated hard disk looks like this: Back: open back cover:
The hard disk consists of a disk body, a control circuit board, and interface components. The disk is a seal that encapsulates the cavities of multiple disks. the control circuit includes hard disk bios, master chip, hard disk cache, and other units. The interface components include power supply, data interface Master/Slave jumper, and so on.
Hard Disk disks generally use alloy materials, most of which are aluminum alloy (IBM has developed a glass disc, it seems that some manufacturers now also produce glass disc, but rare ), the disk is coated with magnetic materials. The thickness is generally about 5mm. Some hard disks only have one disk, while others have multiple disks. The hard disk is mounted on the spindle motor shaft, which is driven by the Spindle Motor for high-speed rotation. The capacity of each disk is called a single disk, and the total capacity of a hard disk is the total capacity of all disks. Because of the low single-disc capacity, there were many disks in the early days. Modern hard disk disks generally have only a few. The record density on the disk is very high, and the disk rotate at high speed during operation. To ensure the stability of its operation and the data is stored for a long time, the hard disk is always sealed inside the hard disk. Hard disks cannot be detached by yourself. In normal environments, dust, fingerprints, hair and other small impurities in the air will cause permanent damage to the hard disk. The following figure shows a hard disk to be unloaded:
Next, let's take a look at the concept of the disk surface, cylinder, disk and sector of the hard disk.
Disk Surface
A hard disk usually has one or more disks. Each disk can have two sides, that is, the front of the first 1st disks is called the 0 side, and the opposite is called the 1 side; the front of the first 2nd disks is called two sides, and the back is called three sides... and so on. Each disk corresponds to a head for reading and writing data. The front of the first disk is called a 0 head, and the back is called a 1 head. The front of the second disk is called a 2 head, and the back is called a 3 head, and so on. The number of disks is equal to the number of cores.
A single-sided disc requires a head, and a dual-sided disc requires two heads. The hard disk adopts a high-precision, lightweight head drive and positioning system. This system allows the head to move quickly on the disk. When reading or writing a hard disk, the aerodynamic effect caused by the high speed rotation of the disk is suspended on the disk, the distance from the disc surface is less than 1 micron (about 1% of the hair diameter), and can be precisely located on the track specified by computer commands in a very short time.
Due to the limitations of the positioning system, the head drive arm can only move between the internal and external magnetic channels of the disc. Therefore, the head is always on the disk, no matter whether it is started or shut down. The difference is that when the disk is shut down, the head stays in the Start and Stop area of the disk, and when the disk is started, the head "flies" above the disk.
Track
Each disc is divided into multiple narrow concentric rings. data is stored on such concentric rings. We call such a ring a track ), each disk can be divided into multiple channels. During shutdown, the head stays in the landing zone of the hard disk, which was previously located in the area closest to the disk center and does not store any data. In the later hard disk technology, some hard disk manufacturers moved this area out of the disk, as shown below:
In the outermost ring of each disk, the farthest place from the disk center is the "0" track, which increases to 1 track and 2 track in turn to the disk center. The storage of Hard Disk Data starts from the outermost ring.
Slice
Depending on the disk type, the number of tracks can range from hundreds to thousands. Each track can store several KB of data, but the computer does not need to read and write so much data at a time. On this basis, each track is divided into several arcs, each of which is called a sector ). The slice is the physical unit stored on the hard disk. Each slice can store 128 x 2n power (n =,) bytes of data. Since the DOS era, each slice is 128 × 22 = 512 bytes. Now it has become an unwritten rule in the industry, and no hard drive vendor has tried to change this convention. That is to say, even if the computer only needs to store a certain byte on the hard disk, it must read all 512 bytes in the sector where the byte is located into the memory at a time, and then select the desired byte.The Slice number starts from 1 instead of 0.. In addition, a hard disk is different from a floppy disk when it is partitioned. In a floppy track, Fan area numbers are arranged in sequence, such as 1st, 2nd, 3rd, and so on. However, in the hard disk track, the fan area number jumps at a certain interval. For example, Sector 2 is not the first sector after sector 1, but the eighth sector in sequence, and sector 3 is the eighth sector after Sector 2, and so on, this "Eight" is called a crossover factor.
It is necessary to describe the origins of this cross factor. We know that Data Reading often requires reading a series of adjacent sectors in order (Logical Data is adjacent ). If the track sector is numbered in physical order, it is likely that after the head reads the first sector, the disk speed is too fast to read the next sector, (It is very time-consuming to know that the distance between adjacent physical sectors is extremely small.) You must wait until a circle is completed. Therefore, crossover is used to solve this problem. The Slice number after the cross factor is added is generally as follows:
Cylindrical
The cylinder is actually a logical concept that we abstract. As mentioned above, the magnetic track farthest from the disk center is a 0 track, and here it is a 1 track and 2 track, 3 channels ...., the same track number on different surfaces forms a cylindrical surface, that is, the cylinder ). Note that the read and write operations on hard disk data are performed by a cylindrical disk, that is, when the head reads and writes data, the operation starts from 0 in the same cylindrical disk, in turn, the operation is performed downward on different disk surfaces (I .e. on the head) of the same cylinder. The head is transferred to the next cylinder only after all the heads of the same cylinder have been read and written, because the selected head only needs to be switched electronically, and the selected cylinder must be switched mechanically. Electronic switching is much faster than moving from a mechanical head to a nearby track. Therefore, read/write data is performed by a cylindrical disk instead of a disk. This method is used to read and write data, improving the hard disk read and write efficiency as much as possible.
Cluster
Set
Several Adjacent physical sectorsIt is called a cluster. The basic unit for the operating system to read and write disks is the sector, while the basic unit for the file system is the cluster ). In Windows, find a file of several bytes, right-click it, and select Properties to see the actual size and occupied space, such as size: 15 bytes (15 bytes), occupied space: 4.00 KB (4,096 bytes ). The occupied space here is the cluster size of your machine partition, because small files will occupy space, the basic logic unit is 4 K, so it will occupy 4 K. Generally, these types of clusters are 4 K, 8 K, 16 K, 32 K, and 64 K. The larger the cluster, the better the storage performance, but the serious waste of space. The smaller the cluster, the lower the performance, but the higher the space utilization. The size of the NTFS file system cluster is 4 K.
Hard Disk data read/write process
Modern hard drive channels use the CHS (cylinder head sector) method. When the hard drive reads data, the read/write head moves along the radial direction to the top of the track where the sector to be read is located, this time is called the seek time (seek time ). Because the distance between the start position and the target position of the read/write head is different, the seek time is also different. At present, the hard disk is generally 2 to 30 milliseconds, with an average of about 9 milliseconds. After the head reaches the specified track, it rotates the disk to make the sector to be read to the bottom of the read/write head. This time is called the rotational latencytime ).
A 7200 (RPM) Hard Disk takes 60 × 1000 Gb/s 7200 = 8.33 milliseconds for each week of rotation, the average rotation delay time is 8.33 milliseconds 2 = 4.17 milliseconds (on average, you need to rotate the half circle ). The average tracing time and average installation latency are called the average access time.
So, let's take a look at the formula for calculating the disk capacity:
Hard disk capacity = number of disks X number of cylinders X number of sectors x 512 bytes
In the blog post "Linux boot process analysis", we mentioned MBR, which exists in the hard disk's 0 cylinder, 0 head, and 1 sector, occupying 512 bytes of space. The 512 bytes contain the main bootstrap loader and the disk partition table DPT. Bootloader occupies 446 bytes, And the Partition Table occupies 64 bytes. A partition occupies 16 bytes. A 64-byte Partition Table can only be divided into four partitions, this is why our hard disk supports a maximum of four partition records.
That is, if you divide the hard disk into four primary partitions, you must make sure that all disk space is used (this is not nonsense ), in general, we divide a primary partition and an extended partition, and then continue to divide the logical partition in the extended partition. Of course, a logical Partition Table also needs a partition table, which exists in the first sector of the extended partition. Therefore, the maximum number of logical partitions is 512/16 = 32, not how many logical partitions can be divided.
Note that the extended partitions we call also occupy Partition Table items. For example, if our hard disk is divided into only one primary partition and one logical partition, the partition table is arranged as follows:
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
The primary partition is shard 1. The extended partition occupies shard 2. The extended partitions 3 and 4 are reserved, and the numbers of logical partitions increase sequentially from shard 5, here we only divide one logical partition.