Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm gonna encrypt a PenDrive using AES (with TrueCrypt). What would be the most efficient allocation unit size when formatting?

Since AES block size is 16 KB, would 16 KB be the most efficient? Is this logic correct?

share|improve this question

migrated from Aug 29 '13 at 20:20

This question came from our site for software developers, mathematicians and others interested in cryptography.

Actually, the AES block size is 16 bytes, not 16 kbytes. In addition, there exist modes of operation for AES where you can encrypt arbitrary bit lengths, hence that need not be an issue. – poncho Aug 29 '13 at 19:40

Focus on your underlying filesystem rather than AES attributes. Here is a list from MS with the default allocation units for different volume sizes under differant file systems/versions. you will not be able to achieve parity between your cypher block size and your file system allocation unit size. in fact trying to do so, may make your cryptography less efficient on a file by file basis, unless your files are very very very tiny.

share|improve this answer

The cluster (allocation unit) size actually has very little if anything to do with the encryption — you'd have the exact same issues with a non-encrypted virtual disk.

Anyway, to quote the TrueCrypt docs (emphasis mine):

"Cluster Size

Cluster is an allocation unit. For example, one cluster is allocated on a FAT file system for a one-byte file. When the file grows beyond the cluster boundary, another cluster is allocated. Theoretically, this means that the bigger the cluster size, the more disk space is wasted; however, the better the performance. If you do not know which value to use, use the default."

Anyway, you almost certainly want to choose the same cluster size as for the disk you're storing the TrueCrypt container on, or possibly an even multiple or fraction thereof, so that the clusters in your TrueCrypt volume are aligned with those on the underlying filesystem (and thus presumably with the sectors on the actual disk it's stored on).

Other than that, it's basically just a speed / space tradeoff. The details will differ depending on the filesystem you're using and the kind of files you want to store (rule of thumb: big files → big clusters, lots of small files → small clusters), but generally the default value should be fine.

share|improve this answer

The cluster size should be chosen based on the sector size of the physical media and the size of the files within the file system. Since a pen drive is flash memory, it uses blocks and pages rather than sectors.

Flash memory blocks are typically 16KiB or 128KiB, with page sizes of 512B or 2048B. The larger/small process flash chips use large block sizes. Therefore it is safe to assume any typical NTFS cluster size is acceptable on flash memory, up to 16KB for most uses. Flash memory is written in blocks, so you should not choose a cluster size larger than the block size unless the files will be rarely modified or are of a large enough size.

It is more complicated when discussing the content of the file system. There is no standard practice, I use set values depending on the type of files I expect, and their average size.

For NTFS, 4KiB is the most common for large disks, but is wasteful when the files are large, like video files and high bitrate audio. The filesystem needs to keep track of which clusters are used for each files, so a 16GiB video file would have 4194304 cluster entries in the file table. The same file on a 64KiB cluster filesystem would only need 262144 entries. If you are expecting only large files that are rarely changed, choose the largest cluster size possible. If the files are small or modified frequently, between 2KiB and 16KiB is the appropriate range.

For exFAT, 32KiB is the most common for external flash memory devices. exFAT was designed with flash memory in mind, and 32KiB is appropriate for most uses, other than larger infrequently modified files, which should use a larger cluster. This filesystem is new, and has limited operating system compatibility.

Using disk encryption software has no relevance on the cluster size, since the cipher block size is smaller than the smallest available cluster size.

share|improve this answer

You must log in to answer this question.