Why is exFAT's default allocation size in Windows so high?

12

1

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?

InsanityOnABun

Posted 2016-12-01T20:58:14.780

Reputation: 223

"Size" and "high" do not go together. Numbers can be "high". "Large" is the bettor word instead of "high". – sawdust – 2018-09-13T21:42:32.797

Possible duplicate of Downsides of a small allocation unit size

– sawdust – 2018-09-13T21:44:09.997

just wanted to mention that I just formatted a 1TB drive using default cluster size, and windows used a cluster size of 2048KB!!! This is not only defying the specs on their page, this is always WAYY too high – woojoo666 – 2018-09-16T09:23:05.283

For anyone who reached this by Googling & might ever back up a git directory to the drive/card in question, it's important to know downside of large sectors, too: each ~200 byte file in a git directory takes up 1 full allocation unit. Large sectors can make dev dirs (which can have 10k+ tiny files) take up a large multiple of their normal HDD sizes. Ex: https://superuser.com/questions/704218/why-is-there-such-a-big-difference-between-size-and-size-on-disk https://superuser.com/questions/1370780/my-sandisk-usb-flash-drive-shows-that-43gb-is-used-when-i-just-copied-a-10gb-fol?noredirect=1&lq=1

– kcrumley – 2019-07-08T18:09:25.503

Answers

11

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.

Muh Fugen

Posted 2016-12-01T20:58:14.780

Reputation: 388

1i did not know about needing to erase flash memory before you could write to it. That makes sense now. Thanks! – InsanityOnABun – 2016-12-02T21:36:05.053

You seem to be assuming that SD cards have no flash translation layer, i.e. that adjacent logical sectors will always be physically adjacent in NAND. Otherwise the logical sectors in a cluster would not have to belong to the same eraseblock. What evidence do you have to support this assumption? – sawdust – 2018-09-13T21:33:02.077