Write in front
This article is some trivial knowledge about hard disks I collected, including the structure of the hard disk, partition, and related knowledge.
Explanation, some pictures in the article come from the Internet. Thank you for sharing!
Hard disk structure and working principle
Regarding the structure and working principle of the hard disk, my description here is relatively simple. If you want to understand in -depth understanding, you can refer to other people’s articles on the Internet. At the end of the article, I will also give a link to the article I think very good, for reference.
hard disk structure
Hard disk stores data based on the principle of electromagnetic conversion.
is seen from the above figure that the hard disk is mainly composed of several plates. They are fixed on the center of the center, which is driven by the motor to rotate at a high speed. The flat cone attached to the surface of the plate is the magnetic head used to read and write data on the plate.
magnetic trail (track): When the plate is rotated at a high speed, every step of the magnetic head will start from the position where it is, and “draw” a invisible circle around the center of the center. This is the magnetic trail.
column (cylinder): Because all the magnetic heads are linked, they step by step or backward, so the same magnetic tract of each plate can form a virtual cylinder, called the column surface. On the hard disk, the access to the data is organized by the column.
sector (sector): Magnetic tract is further divided into sector. Each magnetic trail can be divided into several sectors, depending on the manufacturer of the hard disk, usually 63 sectors.
What needs to be noticed here is,
The number ofmagnetic tract and column surface starts from 0, but the number of the sector starts from 1。
Two different hard disk addressing methods
For the CPU, the hard disk is like a black box, no matter how you organize the CPU! So how does the CPU position the data on the hard disk? This is the address of the hard disk.
So far, there are two main hard disk addressing methods, namely CHS addressing and LBA addressing.
CHS addressing is also called 3D addressing. It is better to understand. It is simple abstraction to the hard disk and uses three numbers to locate the data. C (Cylinder) represents the column surface, H (head) represents the magnetic top number, and S (sector) represents the sector code. According to our description of the hard disk structure, the column surface starts from 0, and the number is numbered from the outside to the inside. The magnetic head is numbered from top to bottom. The sector starts from 1.
Popularity positioning magnetic tract, the magnetic top number is responsible for positioning which disk surface, and the sector number positioning the corresponding sector, so that the address can be determined.
Although the CHS addressing method is simple, it is inconvenient. If you think about it, if there is a lot of data to write, you must also pay attention to the column face number, magnetic head number, and sector number. Therefore, the concept of logical block address was introduced, that is, LBA. LBA is a linear addressing method that imagines hard disk as a linear device, so LBA is a higher level of abstraction than CHS. The LBA addressing mode is supported by the hard disk controller at the first level of the hardware. All efficiency is very high and the compatibility is very good. In the LBA mode, the physical location of the sector does not consider the sector (column number, magnetic top number), but organizes all of them in the same number. Under this addressing method, the original physical sector was organized as a logical sector, and it was There are only the only logical sector code, the only difference isphysical sector number starts from 1, and the logical sector number starts from 0。
For example, there are 6 magnetic heads on a hard disk, 1,000 magnetic trails on each side, and 17 sectors on each magnetic tract. So:
LBA0 corresponds to 0 column surface 0 magnetic head 1 sector
LBA1 corresponds to 0 column surface 0 magnetic head 2 sectors
… …
LBA16 corresponds to 0 column surface 0 magnetic head 17 sector
LBA17 corresponds to 0 pillars 1 magnetic head 1 sector
LBA18 Corresponding to this 0 column surface 1 magnetic head 2 sectors
… …
LBA33 corresponds to 0 column surface 1 magnetic head 17 sectors
LBA34 corresponds to 0 column surface 2 magnetic head 1 sector
LBA35 corresponds to 0 column surface 2 magnetic head 2 sectors
The
… …
LBA101999 sector corresponds to the 999 column 5 magnetic head 17 sectors, which is also the last physical sector on the entire hard disk.
The conversion of two addressing methods
From CHS to LBA, it should be relatively simple, or the above hard disk is inside. What is the LBA if CHS is (1,5,10)?
First of all, the column C is 1, which proves that it has crossed the 0 -column surface, so how many sectors of the 0 -column surface? In other words, how many sectors are there in a column? Obviously, 6 planes, 17 sectors on each side, 6×17 sector.
Magnetic head is 5, which proves that it has passed 5 noodles on the 1st pillar, so the number of sectors over the cross is 5×17
Therefore, it is easy to get the value of LBA 6×17+5×17+(10-1) = 196.
chs-> LBA summary formula is as follows:
lba = C *total number of magnetic heads *Total number of tract sectors + h *Total number of each magnetic sector + (s -1)
The reason why S in the
formula is reduced because the LBA starts from 0.
LBA-> CHS summary formula is as follows:
c = lba / (total number of magnetic heads * Total number per magnetic sector)
h = (total number of LBA / Each magnetic sector) % of the total number of magnetic heads
s = (total number of LBA % per magnetic sector) + 1
Among them (total number of magnetic heads*total number of tract sectors) is the total number of sectors of a column surface,
Reference link:
《Installation system does not ask for people -the secret of the hard disk》
《linux file system (1) -D disk partition physical structure》
《Linux Virtual Filesystem Switch I Disk -related concepts and knowledge》
《Storage basic knowledge -disk addressing (CHS addressing method, LBA addressing method) 》