Referencing this page: https://support.microsoft.com/en-us/kb/140365
NTFS doesn't go over 4KB cluster size until the volume goes over 16TB, and FAT32 maxes out at 16KB in the 16GB–32GB volume range on modern versions of Windows.
exFAT however only defaults to 4KB in the 7MB–256MB volume range. After that it jumps to 32KB in the 256MB–32GB range, and 128KB beyond that.
Why is that? A relatively high cluster size seems wasteful, especially in a format designed for smaller external devices, like flash drives. Doubly so if you're formatting flash memory, because as I understand it, the main benefit to larger cluster size is faster IO due to less fragmentation and less overall clusters to read. Correct me if I'm wrong, but flash memory is much, much less prone to slowdowns caused by fragmentation. So why make the cluster size so high?
Answer
Because exFAT is used primarily for things like large capacity SD cards, and on SD cards you must erase a sector before you can write to it. If you were to use small clusters on a card with a large erase sector size it would result in many erase and write commands to the same sector write a several sequential clusters worth of data to disk not only reducing performance but also prematurely wearing out the flash cells. The erase sector size is generally not documented in card datasheets but can be found in the CSD register of the card. The contents of this register will vary from card to card depending on its internal design. Since SD cards are generally used in things like cameras which store large files, the wasted space of a large cluster size isnt important, and only would be if you were storing very large numbers of very small files which generally does not happen.
This webpage has the contents of this register for about a dozen cards:
http://goughlui.com/2014/01/03/project-read-collect-decode-sd-card-csd-register-data/
And if you enter its contents in to the following calculator you can see for a few of the 32/64GB cards the erase sector size is 128 blocks with a block being 512 bytes. And for a 2GB card the erase sector size is 32 blocks with a block being 1024 bytes.
http://goughlui.com/static/csdecode2.htm
Wether or not Windows is smart enough to query the CSD register and suggest a cluster size, or if it simply guesses based on the partition or disk size is unknown. If you were to emulate a SD card with a microcontroller, you could find out.
No comments:
Post a Comment