OSDev.org
https://forum.osdev.org/

Cluster size vs Sector size
https://forum.osdev.org/viewtopic.php?f=13&t=36431
Page 1 of 1

Author:  siavoshkc [ Fri Jan 10, 2020 4:09 pm ]
Post subject:  Cluster size vs Sector size

I have a confusion on this matter. I read about how FAT16 works and took me 6 hours to understand its working. But I don't know that why we have a sector size and cluster size at the same time? Is it because sector size has to do with hard disk physical property? The unit that FAT16 actually uses is cluster, instead of saving sector per cluster in boot sector, it could save bytes per cluster. This way the HDD geometry could be totally separated from the required data for using it.

Author:  nullplan [ Fri Jan 10, 2020 10:51 pm ]
Post subject:  Re: Cluster size vs Sector size

Sector size is what the drive says it is. Usually 512 bytes, but with more modern AHCI drives, it might also be 4096 bytes. It is not so much a physical property as one of the protocol the drive speaks.

Cluster size is an integer shift of sector size. You usually want to minimize it to minimize fragmentation, but the smaller the cluster size, the more clusters have to be managed, obviously. And for each FAT type there is a maximum number of clusters that can be supported. Also, the smaller the clusters, the more often writing a file has to allocate a new one, which takes time and might introduce internal fragmentation, so it is a bit of a tradeoff.

Saving "bytes per cluster" instead of "sectors per cluster" would in theory uncouple disk geometry from the FS, but for one, sector size has been 512 bytes on many types of drive (so there would be no point), and for two, it is unlikely anyone would ever transfer an FAT image onto a hard disk using large sector sizes.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/