Monday, December 14, 2015

Disk Drive Addressing

Hello everybody , sorry for missed days before as I have some issues but now I have some issue to share with you as usual learn , share and learn then share :D that’s the closed loop which all must in and out = out of life J .
Prepare your triple espresso and come here we have a lot today about HDD addressing.
When you need data your request to access it from HDD especially from  sectors which contain as the sector is the minimal physical unit of transaction between disk and system, we can assume it as 512 bytes. Then there are two methods for addressing CHS, LBA. We have them in details.
Early HDDs have a method in addressing blocks of data that contain which is CHS as C for Cylinder, H for Head and S for sector so when your processor need to access data on your HDD, the last uses CHS to know where that data and access it all is by its controller then returned back to you as example it identifies sector by its position on track which the last is identified by head and cylinder number .  
so sector in this method are grouped under heads by factor called SectorPerHead then heads are grouped under cylinders by factor HeadsPerCylinder the last factor is for device to group all cylinders which is NumberOfCylinders so capacity  is calculated by :
CHS = NumberOfCylinders*HeadsPerCylinder*SectorsPerHead*512 .
Sure you know if one of all these parameters equals 0 so your HDD has something wrong.
CHS is started by (0, 0, 1) = (Cylinder, Head, Sector )
so as you see here:
CHS is designed for drives up to 504 MB sure I mean early IDE/ATA HDDs ,  where
C <= 1,024  , H <=16  and  S <= 63 .
Between 504 MB and 8 Gb there’s  ECHS where E is to Extended and its parameter is :
C < 1,023  , H <255  and  S <= 63 . also C is divided by 2 and H is multiplied by 2 this translation is handled by disk drive controller and you need to know if head is x and platter is y so when HDD contains y then it contains 2x .
Then the second method is called LBA (Logical Block Addressing) where the first sector is 0 so :
CHS (0,0,1) = LBA (0) .  Here the capacity is calculated by:
LBA=(Cylinder*HeadsPerCylinder+Head)*SectorsPerHead+Sector-1
As the device parameter is NumberOfSectors.


in order to optimize I/O the operating system  made cluster which is logical groups of sector that’s why you can see two option is size in any file’s properties like :  

the logical is for cluster and the physical is for sectors  . as the logical is 60952/512 = 119.046875 so this is not a valid number of sectors so the physical size is 120 sectors which is 20*512 = 61440 .

to convert between two modes LBA and CHS use this :
LBA = C x Num_Head x Num_Sec + H x Num_Sec + (S - 1) .


References :