I had a nice post about implementing trim on flash drives and another formatter that implements alignment and enabling write cache for FAT/32 etc, but the forum wouldnt let me post it? A hickup I assume.
SSD and pen drives work with flashmemory which is organized in blocks of a unknown size, probably up to 512 KB, the manufactures don't tell us. For efficient writing the data clusters of the file system should be aligned as good as possible as these flash blocks to avoid unnecessary flash erases.
Therefore new pen drives usually come with a nicely aligned primary partition and a FAT32 file system with aligned clusters, provided the manufacturer made things right...
If a flash drive is partitioned or formatted by the user it is essential to use the right tool. Windows Vista and Windows 7/8 do a good job here. They align new partitions and data clusters very well. In contrast Windows XP creates partitions in the classic way at track or cylinder borders which nearly always results in unaligned partitions.
Data clusters: The NTFS file system has its tables somewhere in the middle of the partition, so the data clusters just start at the beginning, no alignment issues here. FAT/FAT32 have their allocation tables at the beginning, the data cluster follow after some 'reserved' sectors. Modifying the reserved sector count is the key to align the data clusters and this is what Vista and Win7 do very well while XP does a 4K alignment only.
But all this is relative to the partitions!. With non aligned partitions the data clusters are created non aligned too!
I've implemented the display of partition and cluster alignment in ListUsbDrives. As explained above it shows these information only if they are relevant. For SuperFloppy formatted drives there is no partition alignment and for NTFS drives the first cluster alignment is identical to the partition alignment.
Even with a perfectly aligned first cluster, with a cluster size smaller than the flash block size files are perfectly aligned only with a certain probility: If the cluster have half the size of the flash blocks the every second file is perfectly aligned, with a quarter every fourth and so on. Only with clusters of the size of the flash blocks and at least this alignment full write speed is guaranteed.
But larger clusters lead to more non-usable memory (slack space). And with clusters larger than 4KB there is no more NTFS compression.
By the way: TrueCrypt since V6.0 align the data as the container is aligned. From the history: "the start of the data area will always be aligned with the start of a host-filesystem/physical sector"
How to align a partition
Aligning a partition without data loss is reported being possible by means of GParted (based upon a bootable Linux) by moving the partition back and forth, but for a flash drive I think it is not worth the effort. Just delete and recreate it under Vista/Win7.
On "removable" drives the Windows disk management does no like to delete or create partitions. But the Vista/Win7 commandline tool DISKPART can.
Another alternative is the SD Memory Card Formatting Software which creates an partition with aligned clusters on USB "removable" drives. The partition is aligned only if the drive is 4GB or larger, so don't format smaller drives with NTFS after formatting them by means of this software!
A nice and free partition software for Windows which supports alignment is the "Active@ Partition Manager". By default it uses the classic alignment but is offers an option for the exact partition offset. Increase this number to the next value which can be evenly divided by 1024 to get a 512K alignment and decrease the size by the value you have increased the start offset with.
Then it shows a warning plus question "Partition geometry is not aligned with disk track borders. Align on track borders?", we answer "No" because we know better...
Letting format the drive with FAT resulted here in a 1K cluster alignment. Formatting again with XP (FORMAT or dialog) resulted in the expected 4K alignment. So, better let Windows do the formatting...
What will we get? Depends on the device... With an old 128MB SD card I had no improvement of the write speed at all while a Corsair Voyager 16GB writes large files now with 15 MB/s instead of 6.5 thanks to aligned 64K clusters.
USB Write protect as Steve6375's files are forever being flagged by VirusTotal?
Edited by Logic, 23 May 2015 - 10:09 PM.