Archive for February 22nd, 2013
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
/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!