Showing posts with label hard disk drive. Show all posts
Showing posts with label hard disk drive. Show all posts

Friday, September 9, 2011

Formatting of disk

In the previous post, we have seen that a Hard disk drive or a magnetic disk is a collection of platters covered with magnetic material which are grouped into cylinders. Today let's see how the formatting of disk is done.

Initially when the disk is manufactured in industry, it contains nothing except platters with some magnetic material on them. In the factory itself, low level format or physical format happens. First each platter is divided into sectors and appropriate data structures are written into them to enable the disk controller to read or write data. These data structures contain a header, trailer and a data area where the data is read/written. The header and trailer contain information about how to read/write data, along with a ECC(Error Correcting Code). When ever the data is first written on to the sector, from the bytes present in the blocks of sector, the ECC is calculated and updated. When another read/write happens it's ECC is recalculated and compared with the previous one. If both are different, then the ECC may give two kinds of errors in regard to the corrupted bits

1. Soft error which can be treated by correcting code
2. Hard error which cannot be treated in any way. Normally those bits are ignored and no read/write happens to them. The information about these bits need to be stored in header/trailer to make sure no disk I/O happens to them.


Now the disk is fitted into the computer system and sold to vendor, who tries to install Operating system in it. Here is the place where cylinders come into picture. First he partitions the disk, like one disk for Operating system, the other for user files and so on. Each partition is a group of one or more cylinders. These partitions are nothing but your c: drive, d: drive, e: drive etc., In the next step the Operating system needs to install file system in each of these partitions (NTFS, FAT etc.,). Installing of file systems is called Logical formatting which is similar to physical formatting except here, the data structures related to file system I/O are written into sectors.

If you are a user of Linux, you must have already encountered something like "Swap" space. The swap space is created as a partition but no logical formatting is done to it. It is entirely treated as a sequential array of logical blocks, used when ever needed. Most database systems also tend to use swap spaces since these are free from from file system related overhead.

Also the partitioned disk with a file system is called a Cooked disk and the one with out any file system is called a raw disk.

Sunday, September 4, 2011

Hard Disk Drive

Most of us have hard disks in our computers now which are used as a secondary storage devices. As you know that secondary storage devices have non-volatile memory while Primary storage devices like D-RAM have volatile memory.




Ever wondered what lies inside the plastic case of your HDD and how it works. I will show you how..



The above figure is the internal structure of a typical hard disk drive. The hard disk doesn't contain a single disk but a bulk of them which look like CD's and are called Platters. The surface of each platter is logically divided into tracks which are inturn divided into sectors. The both sides of platter are covered with magnetic material. The information is magnetically stored on these materials. There will also be read-write heads used for reading or writing data. These are attached to a disk arm, that moves all the heads as a unit. All the tracks at one arm position form a cylinder.

Transfer time is the time needed for transferring of data between the hard drive and computer. It has two parts

1. The time needed to move the disk arm to the desired cylinder called seek time and
2. The time needed for the desired sector to rotate under the read-write head called rotational latency

Did you ever come across a term called head crash. Head crach occurs when the read-write head makes contact with the disk surface actually. The read-write head just flies on a thin cushion of air above the platter. Although the platters are covered with a thin protective layer, there may be times, when the head damages the magnetic surface. Head crash is irrepairable and the disk must be replaced.