- A new magnetic disk is a blank slate: It is just a platter of a magnetic recording material.
- Before a disk can store data, it must be divided into sectors that the disk controller can read and write. This process is called low-level formatting, or physical formatting.
- Low-level formatting fills the disk with a special data structure for each sector.
- The data structure for a sector typically consists of a header, a data area (usually 512 bytes in size), and a trailer.
- The header and trailer contain information used by the disk controller, such as a sector number and an error-correcting code (ECC).
- When the controller writes a sector of data during normal I/O, the ECC is updated with a value calculated from all the bytes in the data area.
- When the sector is read, the ECC is recalculated and is compared with the stored value. If the stored and calculated numbers are different, this mismatch indicates that the data area of the sector has become corrupted and that the disk sector may be bad.
- The controller automatically does the ECC processing whenever a sector is read or written.
- To use a disk to hold files, the OS still needs to record its own data structures on the disk. It does so in two steps.
- The first step is to partition the disk into one or more groups of cylinders.
- The OS can treat each partition as though it were a separate disk.
- For instance, one partition can hold a copy of the OS's executable code, while another holds user files.
- After partitioning, the second step is logical formatting (or creation of a file system).
- In this step, the OS stores the initial file-system data structures onto the disk.
- These data structures may include maps of free and allocated space (a FAT or inodes) and an initial empty directory.
- When reading sequential blocks, the seek time can result in missing block 0 in the next track. Disk can be formatted using a cylinder skew to avoid this (see Fig. 12.13).
Figure 12.13:
An illustration of cylinder skew.
|
- To increase efficiency, most file systems group blocks together into larger chunks, frequently called clusters. Disk I/O is done via blocks, but file system I/O is done via clusters, effectively assuring that I/O has more sequential-access and fewer random-access characteristics.
Cem Ozdogan
2010-05-25