Clusters, Sectors, and Files A very brief, totally incomplete, and at some times over-simplified introduction Chuck Cusack Some images from Wikipedia and a few other sources
Example: In the City City Block House Rooms
Hard Drives Three ways of thinking about them Physically Conceptually Logically
Hard Drives: Conceptually File System Folders Files
Hard Drives: Physically Medium type Data
Hard Drives: Logically Clusters Sectors Bits 1 …
Example: Revisited City—Hard Drive Block—Cluster Plot of land—Sector House occupies one or more plots Rooms—Bits
Disk Sector Facts (more or less) Typically, disks can be addressed as the sector level, starting with sector 0. A sector can only contain data from one file. A file may be contained in multiple sectors. If the sector size is 512 bytes and a file has 200 bytes, 312 bytes will be unused (wasted). If a disk has 1024 sectors, it can hold at most 1024 files, assuming each is no larger than one sector.
Disk Cluster Facts (more or less) File systems (more on those later) are based on clusters of sectors. A cluster can only contain data from one file. A file may be contained in multiple clusters. If the cluster size is 512 bytes and a file has 200 bytes, 312 bytes will be unused (wasted). If a disk has 1024 clusters, it can hold at most 1024 files, assuming each is no larger than one cluster. Typically, we care about clusters rather than sectors— abstraction!
Cluster Size Does it matter what the size of a cluster is? There are two competing things to consider: The cluster size affects the number of addresses available The cluster size (along with the disk size) affects the number of bits needed for an address Ideally we want to have no limit on the number of files we can store on our disk. Additionally there are benefits (which we won’t discuss in detail) of having shorter addresses.
Cluster Questions What are some of the advantages/disadvantages of small clusters? More files Less wasted space Longer addresses What are some of the advantages/disadvantages of large clusters? Shorter addresses Fewer files can be stored More wasted space
Addressing: Back to the City If I want directions to an address, is “473” enough information? Clearly more information is needed—for instance the street name. If I ask where “473 College Ave” is, I can find it—as long as I know the city. Here think of the city as a disk drive—knowing we are in Holland is like knowing we are referring to the C: drive, for instance.
Addressing: Streets and Numbers Mapping our city analogy to disks slightly differently: A plot of land is like a cluster We will ignore sectors (What concept allows us to do this?) A house is like a file A Disk Drive is a like a city with the following rules All streets are the same length All plots are the same size At most one house per plot A house may take up more than one plot If a house takes up more than one plot, the addresses are “merged” (i.e. some addresses are skipped)
Cluster/Sector Example 16 16 = 256 = 28 clusters (The fact that the grid is 16 by 16 bears no resemblance to reality) 256 8 = 2048 = 211 sectors 20484096 = 8388608 = 223 bytes = 8 MB How many addresses are there? What is the smallest amount of space assignable to a file? How many files can be placed on the drive? What is largest file size possible on the drive? 8 sectors per cluster 4096 bits per sector
Addressing Example I have an 8 GB hard drive with sector size 4096 bytes. How many sectors are there? How many addresses are there (internally)? I format the disk with clusters of size 65536 bytes. How many clusters are there? How many addresses are there (w.r.t. the file system)? How many files can I have? How long are the addresses?
Files Example We can ignore sectors (why?) Might take up part of a cluster But the rest is wasted Might take up multiple clusters Might be split up
Other things The examples here were specific to hard drives Many of the concepts transfer to other forms of mass storage (or secondary storage) Some of the concepts can be translated to memory, although there are some major differences Very loosely speaking (and is some ways not very accurate): Sector Memory Cell Cluster Block (Page?) If you take the Operating Systems class, you may learn a lot more about memory.