Make USB Flash Write Fast Again
I have a 64GB SanDisk Extreme USB flash drive that I use for just about anything. It is a USB 3.0 drive and at the time of purchase, it had the best performance out of all drives in the market.
I can’t remember how fast it was exactly when I first bought it but I remember the read speed was above 200 MB/s and write was above 150 MB/s. But yesterday, a year or so after purchase, I had write speeds of 20 MB/s sometimes falling to 6 MB/s. I wasn’t surprised as I knew at some point all the blocks will be written to and due to lack of support for TRIM, things will get slow — didn’t think that slow!
How do I know it doesn’t support TRIM? If I format and mount an FS with
discard mount option and subsequently run
fstrim /mnt where /mnt
is the mount point of the volume, I get this:
fstrim: /mnt: the discard operation is not supported
OK, but not all hope is lost. I knew about ATA Secure Erase
command. What if that works? Turns out it does and it works so well. I
followed the kernel
guide but here is a summary of commands I ran (change
/dev/X
to appropriate dev) for the impatient. I
strongly recommend reading the full guide.
WARNING as the name suggests, Secure Erase will delete all your data so be sure to make a backup first
- Set a user password (
Nine
is an example, you could use anything):hdparm --user-master u --security-set-pass Nine /dev/X
- Make sure password is set successfully by checking if
enabled is shown under Security section:
hdparm -I /dev/X
- Run the ATA Secure Erase command — mine took 10 seconds:
hdparm --user-master u --security-erase Nine /dev/X
- Verify that security is disabled
hdparm -I /dev/X
After the erase command, I did get an error but it worked nonetheless. Check the before and after graphs of gnome-disk-utility benchmark:
Translations