OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:10 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Cluster size vs Sector size
PostPosted: Fri Jan 10, 2020 4:09 pm 
Offline
Member
Member
User avatar

Joined: Wed Feb 19, 2014 11:10 am
Posts: 40
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.

_________________
Check out my FSB Data Integrity Tester at http://fsbdit.sourceforge.net/.

Siavosh


Top
 Profile  
 
 Post subject: Re: Cluster size vs Sector size
PostPosted: Fri Jan 10, 2020 10:51 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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.

_________________
Carpe diem!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group