当前位置:网站首页>Hard (magnetic) disk (II)

Hard (magnetic) disk (II)

2022-06-26 14:09:00 lengye7

Four 、 The basic composition and working principle of modern disk

 Picture description here

The basic composition of modern disks is shown in the figure above :

serial interface : The serial interface is often directly connected to the main control circuit board of the disk , Used to interact with external devices on the disk , The external device reads data from the disk through this interface , Write data to disk .

Air filter : This kind of air disk is usually used , Used to filter the dust in the air , Once dust gets inside the disk , The disc may be damaged , So that the disk is completely damaged .

Spindle : The motor of the disk disc is connected to the disk disc through the spindle , Thus, the disk can rotate at a high speed .

Disks, disks ( The figure is marked as disk ): This is where information is really recorded , Its surface has magnetic medium .

head : Rely on it to write and read data to the disk .

Magnetic head arm : It connects the magnetic head and voice coil motor , The voice coil motor rotates to move the position of the magnetic head .

Voice coil motor : The peripheral circuit drives it to move the position of the magnetic head .

Permanent magnet : I really don't know what the function is , It should be a part of voice coil motor , Used to provide magnetic field for voice coil motor .

Head parking area : Disk shutdown , When you stop working , The magnetic head stops right here . The magnetic head cannot stand on the disk , Otherwise, the disc will be easily scratched , Cause sector or even track damage .

Now the logical diagram of the disk :

  Workflow for writing data :

Disk controller interacts with external devices , The external device tells the disk controller that data needs to be written , And the disk sector address written .

After the disk controller receives this address , After conversion ( Now they use LBA Address to access the disk , Therefore, the internal disk will calculate according to this address , Calculate the disk surface and track where the sector is located . Specifically, direct use , Or convert to C/H/S In the form of , I don't know .) Put it into the disk address register , Then the disk address register selects the corresponding head according to this address , And control the magnetic head positioning system to position the magnetic head to the corresponding track , After the magnetic head is in place , Read the information on the track immediately , These messages are a series of high and low levels , Corresponding to a series of 0 and 1 Sequence , Sector counters are constantly on these 0 and 1 Find a specific sector start flag in the sequence ( for example 0xD5), After finding the flag, the information of the subsequent sector number is put into the sector compliance comparator , If the sector number matches , Notify the disk controller , Found the corresponding sector ; after , The disk controller controls the writing circuit to write the corresponding information through the magnetic head through the write command , So I wrote it all at once .

In the process we see , The magnetic head can not directly locate the corresponding sector position , The head can only locate the corresponding disk and the corresponding track , The location of the sector depends on the peripheral circuit to find the sector start flag and compare the sector number . This also shows that , The partition of disk sectors is not a physical partition on the disk , It depends on logical division , That is, it depends on the sector start flag information to determine , Once the corresponding sector is found in this process , The disk controller will immediately control the writing circuit to write the corresponding information , This requires the disk controller to respond quickly , After all, the disks of the disk rotate at a high speed , Once the reaction is too slow , The corresponding sector has been missed .

In the process of writing information to the disk above , The disks of the disk always rotate at high speed , It doesn't slow down the rotation just because you look for sectors , It will not stop to wait for the disk controller to respond just because it needs to write data after finding the sector . In the following introduction , You can see clearly , The structure of the disk sector , There is a certain interval between the sectors of the disk , These intervals do not write data , This is to give the disk controller a buffer , So that it can switch the read-write mode of the head , There is also an interval between the sector header and the sector data area , This interval will not write any data , The purpose is to provide a buffer for the disk controller , The disk controller can judge whether to write data to the data area or read data from the data area according to the information of the flag header .

Even when the disk is idle , The disk does not stop rotating ?

First , When the disk is turned off , The magnetic head is parked in the parking area , There is no doubt that .

in addition , The head of a hard disk must not contact the disk , Otherwise, the disc will be damaged , actually , When the disk is rotating at high speed , A circle of high-speed air flow will be formed on the surface of the disk , It is through this air flow that the magnetic head is lifted , The head is very close to the disk , Up to micron level , So that data can be written to and read from the disc .

When the disk is idle , Can the disk be stopped ?

If you want to shut down the disk , Of course it can be , however , The disk must be stopped by sending a shutdown command to it , So at this point , In fact, the disk is turned off , When shutting down the disk , The disk first returns the head to the docking area , Then the rotation of the disc will be stopped . Of course , You may not use the close command , Let the head return to the parking area by other instructions , After the magnetic head is in place , Then turn off the rotation of the disk .

If you just stop the disk from running at high speed , Then it is possible that when the disk is running at a low speed , The airflow can't pull up the head , Then the head contacts the disc , Thus scratching the entire track . therefore , It is very easy to damage the disk by directly powering off , When the machine is switched on and off , Don't cut off the power directly , But through the computer shutdown program to complete the shutdown of the computer . Of course , Modern disks are protected , Once a breakpoint is encountered , The magnetic head will return to the parking area in a very short time , But it is also best not to try to turn off the computer by turning it off .

once , There is an operating system that tries to keep the disk free ( No read / write tasks ), Stop the motor rotation to save power , As a result, the disk is damaged .

The workflow of reading data :

External devices interact with disks , The external device tells the disk control that it needs to read data , And the address of the data to be read .

After the disk controller receives this address , After conversion ( Now they use LBA Address to access the disk , Therefore, the internal disk will calculate according to this address , Calculate the disk surface and track where the sector is located . Specifically, direct use , Or convert to C/H/S In the form of , I don't know .) Put it into the disk address register , Then the disk address register selects the corresponding head according to this address , And control the magnetic head positioning system to position the magnetic head to the corresponding track , After the magnetic head is in place , Read the information on the track immediately , These messages are a series of high and low levels , Corresponding to a series of 0 and 1 Sequence , Sector counters are constantly on these 0 and 1 Find a specific sector start flag in the sequence ( for example 0xD5), After finding the flag, the information of the subsequent sector number is put into the sector compliance comparator , If the sector number matches , Notify the disk controller , Found the corresponding sector ; after , The disk controller controls the readout circuit to read out the corresponding information through the magnetic head through the read command , And put the read information into the buffer of the disk , So a read inside the disk is completed . after , The disk controller will notify the external device , The data has been read out .

In the process we see , The magnetic head can not directly locate the corresponding sector position , The head can only locate the corresponding disk and the corresponding track , The location of the sector depends on the peripheral circuit to find the sector start flag and compare the sector number . This also shows that , The partition of disk sectors is not a physical partition on the disk , It depends on logical division , That is, it depends on the sector start flag information to determine , Once the corresponding sector is found in this process , The disk controller will immediately control the readout circuit to read the corresponding information , This requires the disk controller to respond quickly , After all, the disks of the disk rotate at a high speed , Once the reaction is too slow , The corresponding sector has been missed .

  The above process is the basic process of modern disk reading and writing , It may be different from the specific disk work , But the general process should be consistent .

If you need to use a low-level method to access the disk in the future , In fact, it will be very convenient , Just point out the disk LBA Address , Then write or read , Everything else is done inside the disk . however , Understanding the disk workflow can make better use of the disk , At least it won't make the disk motor suddenly stop .

About the form of hard disk address , Later, we will specifically talk about , Because in the process of hard disk development , The form of the hard disk address has changed many times , The form is chaotic .

5、 ... and 、 The logical abstraction of the disk

The following content is a logical abstraction of the disk and the head , To help deepen understanding .

é»è¾ç»æå¾2
Logical diagram of the core components of the disk

 

English schematic diagram

 Platter: Disc , Disk core components are often composed of multiple disks , Put it all together .

Surfaces: Disk surface , Each disk actually has two sides , Each disk can store data , So each disk surface corresponds to a read-write head .

R/W head: Read write head , One for each panel .

Track: Magnetic track , Each disk is logically divided into multiple tracks , There is an interval between tracks and track time ( Logical intervals , actually , The disk is only through Control the moving distance of the magnetic head to determine this interval , disk There is no division on the disk .), This interval is to prevent the read / write head from affecting the adjacent tracks during reading or writing , As a result, the data of adjacent tracks is lost .

Cylinder: cylinder , The logical division of tracks on all disks is actually the same , Tracks at the same location on all disks are located on the same cylinder .

Sector: A sector , This is the basic unit that the disk provides external data access , Sector is on track , Each track is logically divided into sectors ( There is no physical partition , The division of sectors depends on flag bits , As mentioned in the previous workflow .), There is often a certain interval between sectors ( Logical intervals , This interval is to allow time for peripheral circuits to control the read-write logic of the head conversion ), Through this interval, a certain buffer time is given to the peripheral circuit , To prepare for the next sector .

From the logical diagram of the disk CHS Addressing mode ?

Early disk era , The disk provides access to the outside world by CHS Addressing , such CHS The addressing mode of is exactly corresponding to the structure of the disk .

C------------Cylinder,C Corresponding to the cylinder , The cylindrical surface is determined , The same track on multiple disks is determined .

H------------Head,H Corresponding to the head , Determined the magnetic head , And the magnetic head and disk are one-to-one corresponding , So we determined the disk surface .

adopt C and H, You can determine the unique track .

S------------Sector,S Corresponding to sector , Determines a sector on the same track on all disks .

such , adopt C and H, You can determine a track on a disk , Re pass S, Further determine a sector on the track ,CHS Addressing identifies a sector on the disk .

# The logical structure of the sector  

 The reading and writing principle of hard disk and the generation of disk fragments
Basic schematic diagram of sector

  Let's take a look at the general sector Logical structure

You can see from the above picture that , Sectors as a whole , A sector contains a header and a data area , A certain interval is included on both sides of the sector as a whole , There is also a certain interval between the header and the data area .

You can see from the above picture that , For a sector, it has a header , The flag header is used to determine the start of a sector , It often includes but is not limited to the following information :

  • Sector start flag
  • Sector address ( Should be CHS Address )
  • Sector damage flag
  • Sector damage replacement address ( This usually works after the sector is damaged , Later, we will talk about the repair of bad sectors )
  • Sector verification data

After the header , There is often an interval , This interval is to provide a buffer for these peripheral circuits, including the disk controller , Give them time to process the header data , At the same time, prepare for reading the contents of the following data area or writing data to the data area .

After the header , Is the real data area , The data area contains two parts of information :

  • The real data
  • Verification data about data ( Even now , The data error rate of hard disk is also very high , Every tens of thousands of reading and writing will make a mistake , Therefore, it is necessary to verify the data , In general, simple ECC check )

Sector damage

Sector corruption can often be divided into two categories : Logical corruption and physical corruption .

Logic corruption : The format of the sector is incorrect , The sector cannot be recognized and read , This is logical corruption .

Repair of logic corruption : Logic corruption is easy to repair , Use the low-level formatting tool to re partition the logical sectors of the tracks where the logically damaged sectors are located . Generally, this low-level formatting tool , Every hard disk manufacturer has , It is best to use the tools of the corresponding hard disk manufacturer , And each hard disk will have a low-level format when it comes out , To logically partition sectors for each track .

Physical damage : The disk in the area where the sector is located is damaged , The sector data is not recognized , This is physical damage .

Repair of physical damage : Physical damage can't really be repaired , What the repair tool does is actually map the sectors , When a sector is physically damaged , The repair tool will map this sector to the reserved sector of the disk ( Today's disk manufacturers generally reserve some sectors in the disk , This part of the sector is used to repair the damage , Once the reserved sectors are used up , You cannot continue to repair .). The specific principle is to activate the sector damage flag in the sector header flag , Then fill in the address of the mapped sector in the sector damage replacement address , After doing that , The next time the damaged sector is read , The disk drive will turn to the mapped sector for reading .

Be careful : In case of physical damage , It often means that other parts of the hard disk will gradually begin to damage , This time , It is better to quickly migrate data to a new hard disk , To avoid data loss .

in addition , There are also some sector corruption caused by physical corruption , These damages may not be repaired by the above methods .

# The logical structure of the disk surface

The logical structure of the disk surface of the early disk

  The logical structure of the disk surface of the early disk is shown in the figure above , The number of sectors of the inner and outer tracks is the same , This causes the magnetic recording density of the inner track to be higher than that of the outer track , In fact, the magnetic recording density of the external track can be the same as that of the internal track , So this logical division is actually a waste of division .

later , To increase the capacity of the disk , The logical partition of the disk surface is no longer equal to the sector , It's equal density , That is, the magnetic recording density of the inner and outer tracks is the same , This causes the number of sectors of tracks in the outer region to be greater than the number of tracks in the inner region .

Schematic diagram of sector division of tracks in different regions

  The logical division of the tracks of the current disk should be as shown in the figure above , Its tracks are divided by region , The number of sectors in each region is different , The number of tracks in the external sector is much greater than that in the internal sector . If divided in this way , Because the number of sectors in the external area is more than that in the internal area , But the speed of the disk is certain , So unit time , The external track has more sectors read by the head , Therefore, the data transfer rate of the external track is greater than that of the internal track .

ps: Operating systems like to write their own files to tracks in external areas , After all, the data transmission speed of the external track is faster . such , His files will load faster .

 0 Track : Of the current disk 0 Track number is 0 The outermost track of disk No .

0 The first sector on track No. 1 has a famous name , That's it MBR(Master Boot Record).

stay CHS In addressing mode , Corresponding to CHS 0 0 1. stay LBA In addressing mode , Corresponding to LBA0.

But here's the thing , In some literature , Will still be modern disk 0-63 Sector number is used as Track0. And what is said here Track0, Refers to the location 0 The outermost track on disk No .

  The spacing between tracks

The interval between tracks is a logical interval , Is the disk control and peripheral circuit in the process of controlling the head to write data , Some reserved interval areas , The main function of these spacing areas is to leave a safe area between adjacent tracks , To prevent the head from affecting adjacent tracks in the process of writing or reading data , Cause demagnetization of magnetized regions of adjacent tracks , As a result, the data of adjacent tracks is lost .

When it comes to the spacing between tracks, I have to say CMR And SMR 了 :

CMR(Conventional magnetic recording), Traditional magnetic recording , It maintains the spacing between tracks , Naturally, it has better data security .

CMR Track diagram :

 

SMR(Shingled Magnetic Recording,), Laminated magnetic recording , How does it stack tiles ?

Suppose a track contains 3 part , External track distance a+ Track data area width b+c(a=c), So when writing data, the laminated magnetic recording , Suppose it comes from 0 Track 1 starts writing , At this time, on the disk 0 Track No a0+b+c0 Distance of , Next write 1 Track , This is the time 1 No. track will be covered c0 This interval , therefore 1 Track No a1+b+c1, among a1 It happens to be with c0 Overlapped , Other track writes, and so on , This makes 0 Track and 1 The distance between tracks of the No. 1 becomes a1( Even smaller ), This distance becomes bigger than CMR The small , therefore smr Than cmr With more magnetic recording areas , The magnetic recording density is increased .

And this track structure , It's like tiles stacked up , So it is vividly called laminated magnetic recording .

SMR Track diagram :

 SMR Schematic diagram of track data writing :

  So what are the consequences of shortening the distance between them ?

As above, SMR Write diagram :

When the tracks are too close , During the process of writing data, the magnetic head may affect the remanence intensity of adjacent tracks ( Why would it affect ? Because the width of the head is wider than the width of the data area , When writing data , A portion of the head actually enters the data area of the adjacent tracks .), Once the remanence intensity of adjacent tracks is too low , Data on adjacent tracks cannot be read out , So the data is lost .

So will this kind of consequence happen at any time ?

That's obviously not , The coercivity of magnetic media that can be used in magnetic disks is relatively high , It is not so easy to demagnetize , hypothesis SMR The hard disk is written only once , That's obviously no problem , Because it is only written , So there is only one impact , Then rely on the self coercivity of the magnetic medium , It can completely resist the influence of this magnetic head , Maintain the remanence intensity of the magnetized region .

Now suppose you write 0 After track No , Write again 1 Track , then 0 The data of track No. has been deleted , therefore 0 The sectors of track No. are reclaimed as free sectors , And then again SMR When the hard disk writes data ,0 The free sector of track is allocated , therefore 0 Track number is written to data , This write process affects 1 Data of track No , But also good ,1 Because of the coercivity of the magnetic medium , Its data can still be read out . next ,0 The data of track is deleted again , then 0 Track No. is written data again ,1 Track No. 1 is affected again , Because of the coercivity of the magnetic medium , Once again it resisted the effects , Data can still be read . If the above process is repeated 3 Time 、4 Time 、5 And then ? It also resists the effect of the head writing data , Finally, in the above process, the 6 When the time ,1 The remanence intensity of track No. 1 is weakened to the extent that it cannot be read out ,1 The data of track No. 1 disappeared forever .

Through the process description of the above paragraph , It can be seen intuitively ,SMR The direct problem of increasing the magnetic recording density by reducing the distance between tracks is , If you repeatedly erase a track , This will have a serious impact on the data of adjacent tracks , It will eventually lead to data loss .

To avoid data loss ,SMR The hard disk can refresh the data of a certain track at the same time , It will also refresh all subsequent adjacent tracks , Until all the affected tracks in all the shingle sections are refreshed once . This is a way to protect , But it obviously affects the writing performance of the hard disk , And this method obviously increases the consumption of erasable times of the hard disk , However, the number of erasable disks actually has a lifetime , This leads to SMR The life of hard disk is short .

in addition ,SMR Hard disks usually group tracks , Within the group SMR Track technology , Normal track spacing is used between groups , This is a kind of balance .

Besides ,SMR The hard disk needs to refresh the tracks of all affected shingle parts , If the written data is in different groups , Then such a write will result in SMR The hard disk needs to refresh a large number of stacked tile tracks in the packet , This further reduces write performance . A write process like this , It's actually random , so ,SMR The random write capacity of the hard disk is much lower than CMR Hard disk . Later, someone specially developed the related algorithms , Improved by converting random writes to continuous writes SMR Random write ability .

SMR Group into segment diagram :

 

5、 ... and 、 Addressing mode and capacity of disk

1、 Addressing methods of early hard disks

The addressing mode of the early hard disk was CHS Addressing , This is a corresponding to the hard disk 3D Addressing mode of geometric structure , Because it directly corresponds to the hard disk 3D Geometry , therefore CHS Addressing mode cannot be used for tape , CD, etc .

C:cylinder, cylinder .

H:head, head .

S:sector, A sector .

This addressing method was first used in IBM Of BIOS Use... In the definition , use 24bit Of CHS Mode addressing , among C:10bit( Cylinder from 0 Start counting ),H:8bit( The magnetic head starts from 0 Start counting ),C:6bit( Sectors from 1 Start counting ).

that CHS How is addressing calculated ?

By designation cylinder, Determine the cylinder surface , To determine the track number .

By designation head, Identify the head , So as to determine the disk surface , According to the disk surface and track number , So as to determine a certain track of a certain disk surface .

adopt sector, Determine sector , According to the disk surface, track and sector code , Determine a sector of a track on a disk , Finally find a specific sector . for example 0,0,1 A sector , Is access 0 Track 0 On disk No 1 Sector No , I.e. indicated MBR A sector .

2、LBA(logical block addressing) Addressing mode

In the early days, hard disks were connected to a hard disk card , This causes many compatibility problems between hard disk manufacturers and hard disk cards , Later, in order to solve this problem , Put forward IDE(Integated Drive Electronics) Interface , To solve this problem , At the same time AT Attechment( namely ATA, This version of ATA It is later called Pre-ATA), stay ATA In the proposed LBA Addressing mode , This addressing method solves the problem of CHS Addressing mode can only be used for hard disk addressing , bring LBA It can be applied to addressing such as tape and optical disk .

This version of LBA Use 22bit Width addressing , But unfortunately , Because there are a large number of CHS Addressing mode hard disk , and LBA It is not compatible CHS Addressable hard disk , So the implementation is not smooth .

later ,1994 year ,ATA-1 Release , Put forward 28bit Of LBA Addressing , Have 28bit Of CHS Addressing compatibility mode (C:16bit,H:4bit,C:8bit).

Later it was released ATA-2、ATA-3、ATA-4、ATA-5, No new addressing method is proposed , But keep backward compatibility .

2003 Years issued ATA-6, Put forward LBA-48 Addressing mode , namely LBA The addressing width is 48bit.

that LBA How is it addressed ?

LBA Directly identify each sector , from 0 Disk No. and 0 Track number begins , Mark 0 Sector No ,1 Sector No ... And then there was 0 Disk number one 1 Track ,N+1,N+2, And so on .

When you need to access a sector , Just give the sector code , for example 5 Sector No .

LBA This way , Later, it can also be used for equal density (Zone it Recording) Of disks , Because the inner and outer tracks of this disk have the same density , Therefore, the number of sectors in the inner and outer tracks of this disk is different , Is not very suitable for use CHS It's over .

3、 Hard disk capacity limit breakthrough

1)、BIOS The limit 504MiB Capacity

ATA After the proposal ,BIOS In order to be compatible ATA The hard disk CHS Pattern , Just put 24bit Of H Of 8bit, The simple mapping is ATA Of CHS Mode 4bit, So at this time BIOS The supported hard disk size becomes ( hypothesis 512bytes A sector )1024*16*63*512=528MB=504MiB, This is the first time that hard disk capacity is limited .

In order to break through 504MiB The limitation of ,BIOS Made an extension , take ATA Of CHS Pattern (C:16,H:4,C:8) It maps to C:10bit,H:8bit,C:6bit, So at this time BIOS Can support IDE The capacity of the hard disk is 7.875GiB.

2)、BIOS Once again, the limits of

for the first time BIOS The extension of can only support 7.875GiB Capacity of hard disk , But the hard disk capacity is getting larger and larger , So we soon reached 7.875GiB The capacity limit of .

therefore IBM Jointly released with Microsoft BIOS Enhanced Disk Drive Services(2002 year ) The new BIOS, The BIOS Use 64bit Of LBA Addressing , therefore BIOS The capacity limit of ,BIOS It can support up to 2 Of 64 To the power of 512 Number of bytes .

3)、LBA28 The limitations brought about by

BIOS stay 2002 Year adoption 64bit Of LBA After addressing , The capacity limit has come ATA Of LBA28 here ( Only support 128GiB),28bit Of LBA The hard disk capacity supported by addressing is 128GiB, So in order to break through this capacity , 2003 year ATA-6 Released ,ATA-6 Adopted LBA48bit Addressing , So that the hard disk capacity it can support can reach 128PiB.

But during this period , Because the number of digits in the computer is still 16 Bits or 32 Bit , So the hard disk capacity is still limited to 2TiB.

later 64 Bit machines came out , Capacity is no longer a limitation . at present , The hard disk capacity used in the computer has reached 20TiB.

6、 ... and 、Serial ATA available

The transmission speed of the hard disk is getting faster and faster , however ATA-6 Can only support 133MB/s, therefore intel、IBM etc. , Several other companies have jointly developed Sata agreement ,2003 Years issued sata 1.0, transmission speed 150MB/s,sata Support... From the very beginning LBA48 Bit addressing , Compatible with ATA-1 To ATA-6 Characteristics of , in other words sata1.0 It also supports LBA28 Bit and CHS28 Bit compatible mode .

sata The protocol is not only backward compatible , While maintaining forward compatibility , This makes sata1.0 Your hard disk can be plugged into sata 2.0 On your motherboard , perhaps sata 2.0 Your hard disk is plugged into sata 1.0 On your motherboard , This is a very important feature , be relative to ATA Come on , The advantages are more obvious .

meanwhile ,sata The transmission speed of is also obviously better than ATA, So very quickly ,sata Occupy most of the market share , today (2022 year ), We can hardly find them in the market IDE Interface ATA Hard disk , Almost all sata Interface sata Protocol hard disk .

sata1.0 After the release ,sata2.0 and sata3.0 Also released in succession , The transmission speed reaches 300MB/s and 600MB/s.

原网站

版权声明
本文为[lengye7]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170510559169.html