Hard disk Read and write and fragment generation

Source: Internet
Author: User
Tags valid

The composition of a hard disk

Hard disk We will not be unfamiliar, we can compare it to our computer to store data and information in a large warehouse. Generally speaking, no matter which kind of hard disk, it is composed of several parts, such as disc, head, spindle, control motor, head controller, data converter, interface, cache and so on.

Figure 1 Hard Drive composition diagram

All platters are fastened to a rotating shaft, which is the spindle of the disc. And all platters are absolutely parallel, there is a head on each disk storage surface, the distance between the head and the disc is smaller than the diameter of the hair. All heads are connected to a single head controller, and the head controller is responsible for the movement of each head. The head can move along the radius of the disc, and the disc rotates at a high speed at a speed of thousands of rpm, so that the head can read and write data to the specified position on the platter.

Fig. 2 Disc composition diagram

Because the hard disk is high precision equipment, the dust is its enemy, so must be completely sealed.

Second, the working principle of hard disk

The hard disk is logically divided into tracks, cylinders, and sectors.

Figure 3 Track, cylinder, and sector

Each side of each platter of the hard disk has a read and write head, and the partition of the disk surface area is shown in the figure.

Fig. 4 Partition of Disk panel area

The head near the surface of the spindle contact, that is, the smallest line speed, is a special area, it does not store any data, known as the Kai-stop zone or landing zone (Landing Zone), outside the Kai-stop area is the data area. In the outermost ring, the farthest from the spindle is the "0" track, the hard disk data storage is from the outermost ring start. So how does the head find the position of the "0" track? There is also a component called "0" track detector on the hard disk that is used to complete the initial positioning of the hard disk. The "0" track is so important that many hard drives are scrapped just because of the "0" track damage, which is a pity.

Early hard drives need to run a program called parking before each shutdown, which is to allow the head to return to the shutdown area. Modern hard drives have been designed to discard the small flaws that are not complicated but unpleasant. When the hard drive is not working, the head stays in the start and stop area, and when you need to read and write data from the hard disk, the disk begins to rotate. When the rotational speed reaches the rated high speed, the head is lifted by the airflow generated by the disc rotation, when the head is moved to the area where the data is stored.

The airflow generated by the disc rotation is quite strong enough to hold the head up and maintain a small distance from the disk surface. The smaller the distance, the higher the sensitivity of the head to read and write data, and the higher the requirements for the parts of the hard disk. The disk drives that were designed earlier keep the head in a few microns above the surface of the disk. Later, some designs reduced the flight height of the head on the disk to about 0.1μm~0.5μm, and now the level has reached 0.005μm~0.01μm, which is only 1 per thousand of the human hair diameter.

The airflow can not only keep the head from the opening, but also make it stay close enough to the disk surface, very closely follow the disk surface undulation movement, so that the head flying in a strictly controlled state. The head must be flown above the disc, not the contact plate, which avoids the abrasion of the magnetic coating and, more importantly, does not allow the magnetic coating to damage the head.

However, the head can not be too far away from the disk, otherwise, you can not make the disk to achieve strong enough magnetization, it is difficult to read the magnetization flip on the Chuppan (the form of magnetic pole conversion, the disk is the actual way of recording data).

Fig. 5 Principle of magnetic sheet

The hard disk drive head's flying height is low, the speed is fast, once the small dust enters the hard disk seal cavity, or once the head and the disk body collision, may cause the data loss, the formation bad block, even causes the head and the body the damage. Therefore, the hard drive system seals must be reliable, under the unprofessional condition absolutely cannot open the hard disk seal cavity, otherwise, the dust enters will accelerate the hard disk damage.

In addition, the hard drive head of the search servo motor uses voice coil rotation or linear movement stepper motor, in the servo tracking adjustment to accurately track the disk track, so, hard work without impact collision, moving with care.

This kind of hard disk is uses the Winchest (Winchester) technology to make the hard disk, therefore also is called the Wen Pan, the most hard disk now uses this technology.

Three, disk, track, cylinder and sector

The reading and writing of hard disk is closely related to sector. Before you say sector and read and write principles, say the "Disk", "track", and "cylinder" associated with the sector.

1. Plate surface

Hard disk is generally made of aluminum alloy material substrate, high-speed hard disk may also be made of glass substrates. Each disc of the hard disk has two disk faces (Side), that is, the upper and lower plate surface, generally each disk will be used, can store data, become a valid platter, there are very few hard disk disk number for the singular. Each such effective disk face has a disk number, sequentially numbered from top to bottom from "0". In the hard disk system, the disk number is also called the magnetic number one, because each valid disk has a corresponding read and write head. The disc group of the hard disk is unequal to the 2~14 slice, usually has 2~3 a platter, so the dish number (magnetism number one) is 0~3 or 0~5.

2. Track

The disk is divided into concentric circles when formatted, and these concentric circles are called tracks (Track). The tracks are numbered from within the outward range starting from 0. Each disk of the hard drive has a 300~1 024 tracks, and new large-capacity hard disks have more tracks on each side. The information is recorded in these trajectories in the form of a pulse string, which is not a continuous recording of the data, but is divided into a segment of the arc, which has the same angular velocity. Because the radial length is not the same.

Therefore, the line speed is not the same, the line speed of the outer ring than the line speed of the inner ring, that is, the same speed, the outer ring in the same time period, across the length of the arc than the inner circle across the length of the arc. Each arc is called a sector, the sector is numbered from "1", and the data in each sector is read or written as a unit. A standard of 3. The 5-inch hard disk surface usually has hundreds of to thousands of tracks. The track is "see" is not visible, but the disk surface in a special form magnetized some of the magnetized area, in the disk format has been planned.

3. Cylindrical surface

The same track on all disk surfaces constitutes a cylinder, usually called a cylindrical surface (Cylinder), and the head of each cylinder is numbered from the top down from "0". The read/write of the data is performed by the cylinder, i.e. the head reads/writes the data and begins with the "0" head in the same cylinder. The head is operated on the different disk surfaces of the same cylinder in turn, and the heads are transferred to the next cylinder only after all the heads of the same cylinder have been read/written. Because the selection of the head can only be switched electronically, the selection of the cylinder must be mechanically switched.

The electronic switch is quite fast, much faster than the mechanical head moving to the adjacent track, so the read/write of the data is performed on the cylinder rather than on the disk. In other words, after a track is filled with data, it is written on the next disk in the same cylinder, and a cylinder is filled before it is moved to the next sector to begin writing data. Reading data is also done in this way, which improves the read/write efficiency of the hard disk.

The number of cylinders (or the number of tracks per disk) of a hard disk drive depends on the width of each track (as well as the size of the head), depending on the size of the track interval determined by the positioning mechanism.

4. Sector

The operating system stores information in a sector (sector) on a hard disk, with 512 bytes of data and some other information in each sector. A sector has two main sections: identifiers that store data locations and data segments that store data.

Fig. 6 The working principle of the sector

The first major part of a sector is an identifier. identifiers, which are sector headers, include three digits that comprise the three-dimensional address of the sector: the head (or disk) on which the sector is located, the track (or cylinder number), and the position of the sector on the track, which is the sector area code. The header also includes a field that shows whether the sector can reliably store the data, or whether a fault has been found that is not appropriate for the tag. Some hard disk controllers also record indicators in the sector header, which directs the disk to a replacement sector or track when an error occurs in the original sector. Finally, the sector header is terminated with cyclic redundancy check (CRC) value for the controller to verify the readout of the object of the sector header and ensure accuracy.

The second major part of the sector is the data segment that stores the data, which can be divided into data and error-correcting codes (ECC) for protecting the data. During initial preparation, the computer fills in this section with 512 virtual information bytes (the place where the actual data is stored) and the ECC numbers corresponding to the virtual information bytes.

Four, the hard disk reads and writes the principle

When the system stores the file on disk, it is done by the cylinder, head, sector, which is the first of all sectors under the first head of the 1th track (that is, the first track of the 1th disk), then, the next head of the same cylinder, ..., a cylinder is stored full to advance to the next cylinder until the contents of the file are written to disk.

The system also reads the data in the same order. The data is read by telling the disk controller to read out the cylinder number of the sector, the number of magnets and the sector area code (three components of the physical address). The disk controller directly steps the head part into the corresponding cylinder, chooses the corresponding head, and waits for the required sector to move to the head.

When the sector arrives, the disk controller reads the headers of each sector, compares the address information in these headers with the expected head and cylinder numbers (i.e. seek), and then looks for the required sector area code. When the disk controller finds the sector header, depending on whether the task is a write sector or a read sector, decide whether to convert the write circuit or read the data and tail record.

After the sector is found, the disk controller must process the information for the sector before continuing to look for the next sector. If the data is read, the controller calculates the ECC code for the data, and then compares the ECC code with the recorded ECC code. If the data is written, the controller calculates the ECC code for this data, which is stored with the data. The disk continues to rotate during the necessary processing of the data in this sector by the controller.

V. Generation of disk fragments

As the saying goes, a picture wins thousand words, first uses a acsii code diagram to explain why will produce the disk fragment.

Figure 7 ASCII Chart

The above ASCII diagram represents the disk file system, so I represented him as 0 because there are no data files on it.

On the top and left sides of the graph are a-Z 26 letters, which are used to locate each byte of data, such as the 1th row 1 column is the aa,26 row 26 column is ZZ.

We create a new file, and, of course, our file system changes, and now it's

Figure 8 ASCII chart

As the picture shows: "Content table" (TOC) occupies the first four lines, in the TOC where each file is stored in the system.

In the above diagram, the TOC includes a file named Hello.txt, which is "Hello, World", where the location of the system is AE to LE.

Next, create a new file

Figure 9 ASCII chart

As pictured, we created the new file bye. TXT clings to the first file hello.txt.

In fact, this is the most ideal system structure, if you have your files as shown in the above diagram of a next to one, tightly put together, then read them will be very easy and rapid, because the hard drive in the slowest (relatively) is the transmission arm, less displacement, The time to read the file data will be faster.

But that's exactly where the problem lies. Now I want to add some exclamation marks to "Hello, world" to express my strong feelings, now the problem is: on such a system, the file on the line there is no place for me to put these exclamation point, because Bye.txt occupy the rest of the position.

Now there are two ways to choose, but none of them is perfect.

1. We delete the file from the original location, rebuild a file and write "Hello, world!!" again. – This inadvertently prolongs the read and write time of the file system.

2. Breaking the file is to write an exclamation point in another empty place, that is, "beheaded" – the idea is good, fast, and convenient, but it also means significantly slowing down the time to read the next new file.

If you don't have a concept on the above text, figure

Map of the ASCII image

The two methods described here are like the way our windows system is stored, and each file is next to each other, but if one of the files is to be changed, it means that the next data will be placed in the rest of the disk space.

If this file is deleted, it leaves a space in the system, and as time passes, our filesystem becomes fragmented and fragmented.

Try to be simple, tell the MM to listen to the hard disk read and write principle of simplified version

Fig. 11 Simplified principle of hard disk

The structure of the hard disk is not much said, our usual computer data are on the track, roughly the same as the CD. Reading is done by the head.

Fig. 12 simplified principle of hard disk

As we all know, our data are stored in the form of information in the disk area of the track, the hard drive read by the rocker arm control head from the outside side of the disk surface to read and write. Therefore, the external data reading speed will be much faster than the inside of the data.

Figure 13 Broken disks

In fact, most of our documents are broken, when the file is not broken, the rocker arm only needs to look for 1 secondary tracks and read by the head, only 1 times to be able to read, but if the file broken into 11, then the rocker to look back and forth 11 times the magnetic head for 11 times to read this file completely , the reading time becomes lengthy when it is relatively not broken.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.