Capacity Test For USB Flash Drive Memory

Centon 4 GB USB Flash Drives

Centon 4 GB USB Flash Drives

It’s always a good idea to verify that a USB flash drive works and has its rated capacity, even when you buy them from a reputable vendor.

The easiest way to measure their capacity (quite different than measuring battery capacity):

  • Create a monster file of random data
  • Copy it to the drive
  • Verify that the copy matches the original
  • Delete the copy

That doesn’t verify that you can successfully create a bazillion little files, but it’s a good rough-and-ready check that you haven’t gotten, say, a 2 GB drive mis-labeled as 4 GB. It could happen…

Assuming you’ve deleted any shovelware (these were clean) and that the drives are now empty (as these were), find out how big they claim to be:

df /media/ed/CENTON\ USB/
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/sdb1        4107284     4   4107280   1% /media/ed/CENTON USB

Pour /dev/urandom into a file that will fill the available space (not the total space), which will take several minutes:

time dd bs=1K count=4107280 if=/dev/urandom of=/tmp/test.dat
4107280+0 records in
4107280+0 records out
4205854720 bytes (4.2 GB) copied, 450.883 s, 9.3 MB/s

real	7m31.162s
user	0m0.712s
sys	6m54.166s

Copy it to the drive, using rsync with a progress indicator:

time rsync --progress /tmp/test.dat /media/ed/CENTON\ USB/
test.dat
  4205854720 100%    8.45MB/s    0:07:54 (xfer#1, to-check=0/1)

sent 4206368202 bytes  received 31 bytes  8772405.07 bytes/sec
total size is 4205854720  speedup is 1.00

real	7m59.035s
user	0m24.490s
sys	0m17.433s

Verify that the two files match:

time diff /tmp/test.dat /media/ed/CENTON\ USB
real	3m32.576s
user	0m0.588s
sys	0m6.268s

Then delete the file:

rm /media/ed/CENTON\ USB/test.dat

Repeat as needed for the other flash drives, using the same test.dat file. All these drives worked; one subsequently caught a disease at the library.

And, yes, one of them is noticeably darker; four of the others seem lighter and five darker gray. Most likely, the cases came from three different anodizing batches and, I suppose, if I were to pry them apart, the innards could be radically different. Ya never know!

About these ads
  1. #1 by Raj on 22-February-2013 - 07:49

    Long ago someone gifted me a high capacity pen drive from HK. It showed the rated drive space, when I filled it up with less than half its capacity the drive died! Its sibling with my friend was working fine as he only used a small amount of space.

    • #2 by Ed on 22-February-2013 - 08:04

      Apparently the scammers reprogram the storage capacity fields to a desirably huge number, which works fine as long as you don’t allocate more than the actual capacity. The gotcha comes after you’ve used the drive for a while and the wear-leveling algorithm walks off the edge of the hardware, even on a drive that’s mostly empty.

      Searching on the obvious keywords for counterfeit drives turns up some real horror stories. This being the Internet, some of them might even be true…

  1. Verifying a 32GB MicroSD Card | The Smell of Molten Projects in the Morning