Home |
Sectors, Sector Addressing, and Clusters Logical Drives and Partition Tables The File Allocation Table and Cluster Sizes The ISO 9660 File System Structure The exFAT File System Structure |
Sectors, Sector Addressing, and ClustersMass storage devices such as diskettes or hard disks are frequently referred to as block devices. Software cannot access the device in arbitrarily small units of data. Rather, read and write operations have to be carried out in multiples of a sector. Most disks use a sector size of 512 bytes; however, larger sector sizes are possible. Depending on the physical geometry of a device, addressing a sector may be required in different forms. On a single-sided diskette, a sector can be identified by its track and sector index. On a double-sided diskette, the head must also be known. Most hard disks are implemented as a stack of disks, so the disk must also be specified. On the other hand, a tape device would only require a linear sector index. 16-bit real-mode operating systems such as MS-DOS will normally use the BIOS to access a disk. The BIOS uses the traditional CHS (Cylinder-Head-Sector) addressing scheme, which requires three numbers to specify a sector. Unfortunately, the number of bits allocated for each number was chosen rather small, limiting the accessible disk size to about 8 GB. Newer BIOSes have addressed this deficiency and have defined a set of new, extended BIOS disk services which no longer have these limitations. Because the traditional CHS sector addressing is device-dependent, limiting, and does not match the physical drive geometry on modern disk drives anyway, the LBA (Logical Block Addressing) scheme was introduced. It uses a single 64-bit value to address a sector. The first sector has index 0, the second 1, etc. The mapping of these LBA values onto the physical disk (i.e., the track, head, etc., the sector actually resides on) is performed by the device driver or even the device itself. Internally, RTFiles-32 uses LBA values exclusively. Depending on the device driver used, LBA values may be translated to CHS values, limiting the capacity available with a particular driver. RTFiles-32's floppy driver uses CHS addressing, which is good enough to address floppy disks with only a few MB capacity. Its IDE driver will query the IDE controller for LBA support. LBA is then used if available. Keeping track of a very large number of sectors can be inefficient for a file system. Thus, the FAT file system introduces the concept of an allocation unit or cluster. A cluster is simply a set of contiguous sectors which will be used for file space allocation. For example, if a disk has 1000 sectors, and it is formatted to have a cluster size of 2 sectors, only 500 clusters are available and must be managed by the FAT. Through clusters, the size and number of available allocation units can be adjusted independently of the sector size. The advantage of few large clusters is that the file system needs less overhead for allocation unit housekeeping. The disadvantage is that disk space can be wasted because it is allocated to files in integral multiples of the cluster size. For example, on a volume with a cluster size of 32k, a file of 33k would occupy 2 clusters. Only 1k of the second cluster is actually used, wasting 31k. If the same file is copied to a drive with 4k cluster size, it would occupy 9 clusters, but only 3k of the last cluster would be wasted. Logical Drives and Partition Tables
|