10

I have gone through wikipedia and other sites and here's the information I have obtained.

Sector: Smallest Addressable Unit (mostly 512 bytes)
Cluster: Smallest Allocation Unit (equals to 1 or more sectors and the number of clusters depends on the file system).

Let's say in the below example: sector =512 bytes and a cluster =8 sectors=4096 bytes. Now, I am having a hard time figuring out, when I am trying to create a file what does the file system do? Does it consider 4096 bytes as the smallest write/read unit or 512 bytes?

If the answer is 4096 bytes: When the manufacturer of the disk drives has provided 512 bytes as the smallest addressable unit, why does the file system consider cluster as the smallest unit? I mean, what are the advantages in doing so?

8

The advantage of file systems considering a cluster/allocation unit/block as the smallest unit, is because addressing the entire disk per-sector would require a larger number of bits to index it all. This larger number of bits would make it slower, because there are a larger number of addresses and things to keep track of. It's far more efficient to address (and index!) locations using say, 48 bits (2^48 = 2.8e14), as opposed to 64 or more bits (2^64 = 1.8e16) for each single access of the device.

But yes, cluster size or allocation unit size (windows) or block size (Linux) is adjustable depending on the file system defined, and that is the smallest size that can normally be accessed by an OS to store file data. "Defining a filesystem" means to format the disk (or the specifications of that format), so implies erasure of all data on the disk. So on a disk with a cluster size of 4kiB, a 1-byte file would indeed take up an entire 4k cluster as in your example. Yes, the OS could write to some specific sector within that cluster, but the file will still use the same sectors of that cluster (file size will always be a multiple of cluster size, regardless of what data is in it.) To change that cluster size, means to re-format the disk, and is why all data must be erased.

Incidentally, smaller cluster sizes store small files more efficiently. However, the disk will run slower overall as a consequence, because of the increased number of clusters. When your PC is just sitting there grinding on the disk for a long time, this is because it's trying to read or write so many small blocks, and the sheer number of them slows everything down.

Ex: 100,000 768-byte files, stored on a disk with 1kiB clusters:

  • 768kB bytes of actual file data

  • 1.024MB of the disk used, because each file uses 1024 bytes of the disk.

  • Space efficiency = 0.768/1.024 = 75% (not bad...)

And likewise, larger clusters are better for disks with fewer, larger files on them like movies, images, and audio. Since there are fewer clusters, the disk is generally faster. But be careful putting lots of small files on it:

Ex: 100,000 768-byte files, stored on a disk with 64kiB clusters:

  • 768kB bytes of actual file data

  • 6.55GB of the disk used, because each file uses 65535 bytes of the disk.

  • Space efficiency = 0.768/6553.5 = 0.00017% !!!

Disks with mixed content, such as an operating system, generally have medium-to-small cluster/block sizes, as most of the files are medium-to-small in size. The end result is a compromise between space utilization and speed.

The disks themselves prefer anywhere from 32kB to 256kB blocks, as that allows them to transfer the most data per second.

This is all concerning traditional mechanical, rotating-platter magnetic-storage hard disks. SSD's or Solid-State Drives are quickly replacing traditional hard disks and boast much faster read/write/seek speeds. So is cluster size important on a SSD today? Well I'd say it is less important to the average user, but only because the SSD (and modern computers) are much faster already. Who is going to notice a SSD slow-down of 10% when already 5x faster than a magnetic hard disk?

What might influence the cluster size on a SSD more is the throughput. You might find (by formatting and benchmarking) that a certain cluster size works far better than others for that SSD. For example, some SSD's are optimized for 8kiB or 4kiB transfers. This has to do with how big a block of data the electronics inside are prepared to transfer per request. Match what the OS is attempting to use (cluster size) with the optimal size for that SSD = fastest transfer speed.

Cluster size is still important for file "overhead" reasons on SSD's however.

I've found a great tool for benchmarking SSD's is AS-SSD for Windows and these on Linux.

| improve this answer | |
  • 2
    Cluster size is indeed "easily" adjustable, though it requires re-formatting the volume. Windows refers to it as "Allocation unit size". – Marc.2377 Jun 7 '16 at 23:54
  • 1
    "cluster size ... is the smallest location that can be accessed by an OS" -- No, the cluster size applies only to allocation of the data area of the filesystem. I/O can still be performed on just a sector, i.e. less than the size of a cluster. BTW "cluster" is a term essentially exclusive to Microsoft filesystems. – sawdust Feb 9 '17 at 0:43
  • Does the old wisdom about larger allocation units being more efficient apply in today's age of SSDs (where random IO is (theroetically) just as fast as sequential IO?) or even 3DXPoint where each byte is directly addressable? – Dai Jul 19 '19 at 1:31
-1

Sector size defined by Manufacturer.

Now we can see two kind of sector size. 512b or 4Kb

Before 2010 year HDD Sector size: 512b

After 2010 year Manufacturer start produce HDD 4K defends on brand.

Now 2018 year, many Users over 70% use 512b sector size.

Rarely some HDD manufacture provide own tool to change sector size.

Cluster(for FAT) is the same as BLOCK(for Linux) system.

It contains one or more several sectors

File system deal with cluster(or block) only.

Logical sector called native sector provided by manufacture.

User can change only Physical sector(=Cluster or Block size) by format or partition tool.

Logical sector/Physical sector = 512/4096 = manufacturer sector/user sector = unable change / change

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.