6

As far as I know, there was no TRIM/UNMAP support in Windows before 7 (special tools were used for SSD drives), but flash drives were used since about 2005 and were fully supported by Windows XP.

As USB mass storage devices, they were using the SCSI protocol on top of USB (am I right at this point?). There is UNMAP in SCSI, but it was not supported in Windows XP as well.

So, the only chance for a USB flash drive to know some block may be deleted is a write request from the OS.

That means after some usage, the whole drive is dirty and it is always slow. There is no way to tell it to delete any block. You only can throw it away and buy a new USB flash drive.

But I am sure that this is not how it was. What did I miss?

10
  • TRIM doesn't effect nor is it used on flash drives even on OSs that support it. The reason that is the case is that TRIM isn't used on removable drives.
    – Ramhound
    Jan 29, 2017 at 23:15
  • 1
    @Ramhound so when does flash drive delete blocks? UNMAP is supported on USB Attached SCSI, but only on USB 3.0 and Windows 8
    – user996142
    Jan 29, 2017 at 23:17
  • 1
    I would have to research that topic before I answered your question. The only thing I do know is TRIM is not applicable to removal flash devices.
    – Ramhound
    Jan 29, 2017 at 23:21
  • 1
    It says USB Attached SCSI enables TRIM and supported since Win8 (en.wikipedia.org/wiki/USB_Attached_SCSI), but there is no source. I was thinking that similar memory (i.e. NAND MLC) is used both in SSD and Flash Drives
    – user996142
    Jan 29, 2017 at 23:29
  • 1
    @Ramhound: How's the NAND flash memory on an SSD different compared to a USB flash drive? Aug 26, 2022 at 19:12

2 Answers 2

8
+100

The short general answer is: thanks to a hidden amount of NAND cells.

The controllers of flash drives maintain write performances by applying a garbage collector mechanism: the fragmented free logical sectors are gathered and mapped to free physical NAND blocks. The garbage collector is not controlled at all by the OS, this is a background process that is fully internal to the drive (the drive just need to be powered on).

If there is no more free space on the drive then obviously the garbage collection can no longer work (note that this happens only if the drive has been entirely filled up at some point).

To overcome this problem, there is a hidden amount of NAND cells on most drives: even if the drive is "logically full" (from the OS point of view), it is not "physically full", and the controller has still some room to apply the garbage collection. https://www.seagate.com/fr/fr/tech-insights/ssd-over-provisioning-benefits-master-ti/

Now, the hidden volume of cells depends on the drive category: a high-end drive will have a large volume, while an entry-level drive has a minimal amount. I also think it's safe to assume that cheap USB keys do not have any hidden cell.

Similarly, not all drives have a clever garbage collection mechanism, some drives may have a rough one, and some drives (cheap USB keys again) may not have any garbage collector.

All what I have written above applied even without TRIM.

2
  • two notes: 1) if the drive does not support TRIM (must support UAS and UNMAP for that), you might consider over-provisioning the drive yourself as the first step right after taking the new device out of its blister, as this might be your only chance to do it. (this supposed a reasonably good device that does not need and is not optimized for the FAT partition it comes pre-formatted with.) rewrite a new GPT (or delete de existing partition) and create a new partition (FAT32/NTFS/exFAT/ext4) leaving out the last part of the disk unused. i reserve 1/8 of my drives this way.
    – Lanchon
    Oct 16 at 11:57
  • and: 2) some drives may reclaim a block as unprovisioned (the equivalent of a TRIM action) if all-zero data is written to it. on a half-used drive that got seriously slow, you can create a file copying from /dev/zero until the drive is full and then delete it. this might do nothing (burn life out of your flash) or TRIM it. you should be able to see the difference by benchmarking. also, you may notice that writing zeros is faster than general writes, and that is clue the writes are being handled in a special manner. (still, option 1) above is definitely the safer option.)
    – Lanchon
    Oct 16 at 12:05
3

There exist too many flash-drive technologies to give anything but a very general answer. Below is some advice, keeping in mind that most flash drives are manufactured cheaply with hardware that degrades over time.

  • ATA Secure Erase is an alternative to TRIM for some drives. in the article Make USB Flash Write Fast Again the author used it to increase the write performance of a 64GB SanDisk Extreme USB flash drive from 81.7 MB/S to 149.7 MB/S.

  • Weak sectors on the disk might be improved by a format ("slow" - not quick)

  • The NTFS format may be more efficient than FAT32 and exFAT. See for example the article FAT32 vs. exFAT vs. NTFS USB3 Performance Comparison.

  • In Device Manager, setting the USB to "Better performance" rather than "Quick removal" will enable Windows to better cache the data, but will require to always remember to eject the drive after write.

  • Update drivers for the device and/or the USB controller.

  • A USB port that is used frequently might degrade over time, so try another port, changing between front and back ports of the case.

6
  • What is a "Weak sector"? And as for the last point "A USB port that is used frequently might degrade over time...", what do you mean, and do you have a reference?
    – PierU
    Sep 19, 2022 at 12:56
  • @PierU: A Weak sector is one that has not failed, but that reading it requires several attempts so slowing the read, fixed by rewriting to refresh it. For USB ports working badly on one controller but working fine on same computer but another USB controller, you will find enough posts on the internet and some on our site.
    – harrymc
    Sep 19, 2022 at 13:41
  • OK for what is a "weak sector", but AFAIK a simple format won't fix them. About the USB ports, this is the "...might degrade over time" that shocks me: I haven't heard about that before.
    – PierU
    Sep 19, 2022 at 14:09
  • @PierU: You need a "slow" (not quick) format.
    – harrymc
    Sep 19, 2022 at 14:12
  • it's worth mentionning ;)
    – PierU
    Sep 19, 2022 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .