I. Hard Disk
Composition
Hard drives are no stranger to everyone. We can compare them to our computers.
A large warehouse that stores data and information. Generally, either hard disk is composed of disk, Head, disk spindle, control motor, head controller, data converter, interface, cache, and other parts.
Figure 1 hard disk Composition
All the disks are fixed on a rotating axis, which is the disk spindle. All disks are absolutely parallel, and each disk has a head on the storage surface. The distance between the head and disk is similar.
Hair
The diameter of the wire is small. All heads are connected to one head controller, and the head Controller is responsible for the movement of each head. The head can act in the radius of the disk, and the speed of the disk is tens of thousands to tens of thousands per minute.
This allows the head to read and write data at the specified position on the disk.
Figure 2 disk Composition
Because the hard disk is a high-precision device and the dust is its enemy, it must be completely sealed.
Ii. Working Principles of Hard Disks
Hard Disks are logically divided into tracks, cylinders, and sectors.
Figure 3 track, cylinder, and sector
Each disk has a read/write head on each side of the hard disk.
Figure 4 Disk Area Division
The head is close to the contact surface of the main shaft, that is, the place with the smallest wire speed. It is a special area that does not store any data. It is called the start/stop area or the landing area (landing ).
Zone. In the outermost ring, the farthest place from the spindle is the "0" track, and the storage of Hard Disk Data starts from the outermost ring. Then, how does the head locate the position of the "0" track?
What about it? There is also a component named "0" track detector in the hard disk, which is used to complete the initial positioning of the hard disk. The "0" track is so important that many hard disks are scrapped only because the "0" track is damaged.
It is a pity.
A program called parking needs to be run before each shutdown of a hard disk in the early days. Its function is to let the head back to the start and stop area. The Design of Modern hard drives has been abandoned. Although not complex, it is very difficult.
No renewal
Fast small defect. When the hard disk does not work, the head stays in the Start and Stop area. When you need to read and write data from the hard disk, the disk starts to rotate. When the rotation speed reaches the rated high speed, the head is lifted by the airflow generated by disk rotation,
Then the head moves to the area where the disk is stored.
The airflow generated by disk rotation is strong enough to hold the head and keep a tiny distance from the disk surface. The smaller the distance, the higher the sensitivity of the head to read and write data, of course, the higher the requirements for each part of the hard disk. Disk drives designed earlier
Enables the head to fly several microns above the disc. Later, some designs reduced the flying height of the head on the disk to about 0.1 μm ~ 0.5 μm, the current level has reached 0.005 μm ~ 0.01 μM, which is only 1‰ of the diameter of human hair.
The airflow not only separates the head from the opening surface, but also keeps it close enough to the disk surface, closely following the ups and downs of the disk surface, so that the head flight is strictly controlled. The head must fly above the disk surface rather than touching the disk surface. This position can avoid scratches on the magnetic coating, and more importantly, prevent the magnetic coating from damaging the head.
However, the head cannot be too far away from the disk surface. Otherwise, the disk surface cannot be magnetization enough, and it is difficult to read the magnetization of the disk (pole conversion form, is the method of actually recording data on the disk ).
Figure 5 disk Principle
Hard Disk
Driver
The flying floating height of the head is low and the speed is fast. Once a small amount of dust enters the hard disk Seal Cavity or the head and the disk body collide, it may cause data loss and form bad blocks, it may even cause damage to the head and disk. Therefore, the hard disk system must be sealed reliably. In non-professional circumstances, it is absolutely impossible to enable the hard disk sealed cavity. Otherwise, the damage to the hard disk will be accelerated after dust enters.
In addition, the track-seeking servo motor of the hard drive head mostly uses the audio ring rotation or linear motion stepping motor to precisely track the track of the disc under the adjustment of the Servo Tracking, when the hard disk is working, do not have an impact collision. Be careful when moving it.
This type of hard disk is a hard disk manufactured by Winchester, which is also called a warm disk. Currently, most hard disks use this technology.
Iii. disc, track, cylinder, and fan Area
Hard disk read/write is closely related to the sector. Before talking about the sector and read/write principles, let's talk about the "disk", "track", and "Cylinder" related to the fan area ".
1. Disk Surface
Hard Disk disks are generally made of aluminum alloy materials as substrates, and high-speed hard disks may also be made of glass as substrates. Each disk on a hard disk has two sides, namely, the top and bottom sides. Generally, each disk has two sides.
Benefit
Can be used to store data, to become a valid disk, there are also a few hard disk surface number is singular. Each valid disk has a disk number, which is numbered from top to bottom from "0" in sequence. On Hard Disk
In general, the disk number is also called the head number, because each valid disk has a corresponding read/write head. The disk group of the hard disk is 2 ~ 14 pieces, usually 2 ~ Three disks, so the disk number (head number) is 0 ~ 3 or
0 ~ 5.
2. Track
The disk is divided into many concentric circles during formatting. These concentric circle tracks are called tracks ). The track starts from 0 in sequence. Each disk on the hard disk has 300 ~ 1
024 channels, with more channels on each side of the new large-capacity hard drive. Information is recorded in these tracks in the form of a pulse string. These concentric circles are not recorded continuously, but are divided into arcs in the segment.
The same speed. Because the radial length is different.
Therefore, the wire speed is also different. The wire speed of the outer ring is higher than the line speed of the inner ring. That is, the length of the circular arc that is crossed in the outer ring is greater than that of the inner ring at the same speed.
The arc is of a large length. Each section of an arc is called a slice. The Slice starts from "1" and the data in each slice is read or written as a unit at the same time. A Standard 3. A 5-inch hard disk usually has several hundred
Thousands of tracks. The track is invisible. It is only some of the magnetized areas on the disk surface that are magnetized in special forms. It has been planned during disk formatting.
3. cylindrical
A cylinder is a cylinder formed by the same track on all disks. The head of each cylinder starts from "0" from top to bottom. Data reading/writing is performed by a cylindrical column,
Magnetic
When reading/writing data from the header, the first operation starts from the "0" head in the same cylinder, and then the operation is performed on the different disk faces of the same cylinder, that is, the head, only after all the heads in the same cylinder have been read/written
To the next cylinder, because the selected head only needs to be switched electronically, and the selected cylinder must be switched mechanically.
The electronic switching speed is much faster than that of the mechanical head moving towards the adjacent track. Therefore, data reading/writing is performed by the cylinder instead of by the disk. That is to say, after a track is full of data, it is written on the next disk of the same cylinder. After a cylinder is full, it is moved to the next sector to start writing data. Reading data is also carried out in this way, which improves the hard disk
Read/write efficiency.
One hard drive
The number of cylinders (or the number of tracks on each disc) depends on the width and width of each track (likewise, it depends on the size of the head ), it also depends on the gap between tracks determined by the positioning mechanism.
4. Sector
Operating System
Information is stored on the hard disk in the form of a sector (sector). Each sector contains 512 bytes of data and other information. One slice has two main parts: the identifier of the location where the data is stored and the data segment where the data is stored.
Figure 6 Working Principle of slice
The first major part of a sector is the identifier. The identifier is the Sector Header, which consists of three digits that constitute the three-dimensional address of the sector: the head (or disk) of the sector, the track (or cylindrical number), and the sector
In the Magnetic Field
The path is the fan area number. The header also contains a field that shows whether the slice can store data reliably or whether a fault has been found and thus is not suitable for use. Some hard drive controllers are in the Sector Header
The indicator is also recorded to guide the disk to the replacement sector or track when an error occurs in the original sector. Finally, the sector header is ended with the cyclic redundancy check (CRC) value, so that the controller can check the reading status of the Sector Header,
Ensure accuracy.
The second major part of the slice is the data segment that stores data, which can be divided into data and the Error Correction Code (ECC) that protects the data ). During the initial preparation, the computer fills in this section with 512 virtual information bytes (actual data storage location) and ECC numbers corresponding to these virtual information bytes.
Iv. Hard disk read/write principles
When the system stores files on a disk, it uses the cylindrical, Head, and sector method, that is, the first Magnetic Head of the 1st track (that is, the first Magnetic Track of the 1st disk) and then the next head of the same cylinder ,......, After a cylindrical storage is full, it is pushed to the next cylindrical until all the file content is written to the disk.
The system also reads data in the same order. When reading data, the disk controller is notified to read the cylindrical number, head number, and fan area number of the slice (three parts of the physical address. The disk controller directly moves the head parts to the corresponding cylinder, selects the corresponding head, and waits for the required sector to move to the bottom of the head.
When the slice arrives, the disk controller reads the header mark of each slice, compares the address information in the header mark with the desired head and cylinder number (I .e., seek), and then, find the required fan area number. When the disk controller finds this sector header, it determines whether to convert the write circuit or read data and tail records based on whether the task is to write a sector or read a sector.
After a sector is found, the disk controller must post-process the information of the sector before continuing to search for the next sector. If the data is read, the Controller calculates the ECC code of the data, and then
Compare with the recorded ECC code. If the data is written, the Controller calculates the ECC code of the data and stores it together with the data. The disk continues to rotate when the controller processes the data in this sector as necessary.
V. Generation of disk fragments
As the saying goes, let's use an ACS first.
I code diagram to explain why disk fragmentation occurs.
Figure 7 ASCII chart
The ASCII diagram above indicates the disk file system. Since there is no data file above, I have expressed it as 0.
There are 26 letters A-Z on the top and left of the graph, which is used to locate the specific location of each data byte. For example, the value of column 1 in row 1st is AA and that of column 26 in row 26 is ZZ.
We create a new file. Of course, our file system has changed.
Figure 8 ASCII chart
: "Content table" (TOC) occupies the first four rows and stores each file in the TOC in the system.
In TOC, a file named hello.txt is stored in the file "Hello, world". The location in the system is AE to le.
Next, create a new file.
Figure 9 ASCII chart
, The new file bye. TXT is attached to the first file hello.txt.
In fact, this is the most ideal system structure. If you put all your files together as shown, then they will be very easy and fast to read, because the hard disk
The slowest movement in the drive arm (relatively speaking) is less displacement, and the time for reading file data will be faster.
However, this is the problem. Now I want to add some exclamation points after "Hello, world" to express my strong feelings. Now the problem is: on this system, there is no place for the document to let me put this exclamation point, because bye.txt occupies the rest.
There are two methods to choose from, but none of them are perfect.
1. delete the file from the original location, create a new file, and write "Hello, world!" again !!". -This inadvertently extended the reading and writing time of the file system.
2. to break a file, you just need to write an exclamation point in another blank place, that is, a different place.-This idea is good, fast, and convenient. However, this also means that reading the next new file is greatly slowed down.
If you have no idea about the above text,
Figure 10 ASCII chart
The method 2 mentioned here is like the storage method of our windows system. Every file is adjacent, but if one of the files needs to be changed, this means that the data will be stored in other spare parts of the disk.
If this file is deleted, spaces will be left in the system. Over time, our file system will become fragmented and fragments will be generated.
Try to make it simple and tell mm the hard disk
Read/write principles simplified version
Figure 11 hard drive principle simplification
The hard disk structure is not much said. We usually use computers
The data is stored on the track, which is roughly the same as that on the CD. Reading is performed by the head.
Figure 12 hard drive principle simplification
We all know that our data is stored on the track of the disk sector in the form of information, and the hard disk reading is read and written from the outside of the disk to the inside by the rocker head. Therefore, the external data reading speed is much faster than the internal data.
Figure 13 broken Disk
In fact, most of our files are broken. When the files are not broken, the rocker only needs to find one track and read it from the head. Only one time is required to read the files; however, if
The file is broken into 11 parts, so the rocker side needs to search for 11 times of Magnetic Track head for 11 times to read the entire file, and the reading time becomes lengthy when the file is not broken.