Saturday, July 7, 2018

filesystems - What allocation unit size to use when formatting a USB flash drive in FAT32?


I want to use Windows 7 to format a ~4 GB USB flash drive in the FAT32 file system. (I want to format it in FAT32, not NTFS.)


In Windows Explorer, I right-click the flash drive and click Format.



  • The Format dialog box appears [(A) below].


  • The allocation unit size is set to 4096 bytes when the dialog box opens, but when I open the pulldown menu [(B) below], I see that there are other choices.


  • When I click the Restore device defaults button, the allocation unit size is changed to "Default allocation size" [(C) below], although it fails to specify what the default allocation size actually is.



Windows 7 format


What allocation unit size should I use for this ~4 GB USB flash drive, and why?


Would the answer be different for a different capacity flash drive (~16, ~32, or ~64 GB, for example)?


(I want to be able to use the flash drive on both Windows and Mac, so I am choosing FAT32. I will be storing some mp3 on the flash drive.)


Answer



In general:


It depends on what kind of data you are intending to store on the device.
For all data storage media types at all sizes:



  • Small cluster sizes are more suitable for many small files such as documents and plain text.

  • Large cluster sizes rather match large files. This is more multimedia-oriented.

  • In today's world, it makes no noticeable difference as it did decades ago. Feel free to use the pre-selected cluster size, which is usually 4 KB (4096 Bytes).


Let's dive into the details.



  • Even an empty file would take the full block size on FAT32. Newer and more modern file systems such as BtrFS and ext4 have more efficient ways of handling it. The latter one, and possibly both for instance are able to store multiple small files in one cluster. But that is also an ancient problem due to extremely developing storage sizes.

  • If a file grows beyond any single/multiplied cluster size (e.g. for 4KB cluster size: 4096, 8192, 12288, 16384, 20480, n×4096, etc…), and the next cluster after the file is already used by a different file, fragmentation happens.

  • FAT32 is the default and most commonly supported USB file system for embedded systems such as car radios and USB HiFi, Boomboxes for your music. It is possible, that specific devices suffer from compatibility problems with exotic cluster sizes. You may try out a few, but the default 4 KB (4096 Bytes) is the most likely size to be supported.


Because flash drives (i.e. SDD, SD, USB) have closely zero access times and no moving parts, file fragmentation is less of a problem there. There is no head that needs to jump to and seek the data block position LBA (logical block address) of where the file continues. This is normally no noticeable delay, but can turn into a minor problem, if an operating system is running on that disk, and needs access to many files and huge amounts of data in real-time.


But a larger cluster size results into fewer clusters holding more data, which makes it easier, thus faster for the computer to handle.


Today's computers are so fast, that, as already mentioned, the selected cluster size does not make much of a difference in average usage cases, especially for flash drives. Hard drives are prone to performance drops with increased file fragmentation, but modern operating systems and file systems regularly defragmentize by default, and even allow using RAM and auxiliary storage (ie.SSD) as block cache, where frequently used data will be stored onto for faster access.


That is the process of reversing the file fragmentation, simply said. The dedicated Wikipedia article shows a graphical animation, which may help your understanding.


Graphical animation: Illustration of file fragmentation and defragmentation.


Summary: It makes no relevant difference in today's world in your case.


Music, what you mentioned in your question, does not require extreme reading speeds at all. Even the reading speed of floppy disks is sufficient for music.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...