On 07/08/2015 09:54 AM, Kaza Kore wrote:
I have recently bought some large USB keys to use as
backup storage
to replace my old moving disk external hard drive. Due to the worry
of the reports of fakes reporting to be large drives, even when
plugged into the system, I wanted to test these before using them for
real. Seems best way to do this is fill the drive up and check data
for integrity. So first step will be to create a 8GB file which I
will copy multiple times.
Have you heard of the ISAAC cryptographic pseudo-random number generator
(CPRNG)?
http://burtleburtle.net/bob/rand/isaacafa.html
Given seed value(s), it will generate a repeatable sequence of "random"
integer values. Cycles should be more than long enough to fill your
device before the sequence repeats (you could save the first block of
values for detection and generate a warning if this occurs).
You could generate a sequence of values, write them to the device one
block at a time (4096 bytes, far more efficient and easier on your flash
memory than writing one integer at a time), wait for the device to fill,
reset ISAAC, read the blocks back, compare to ISAAC values, and keep a
running count of good and bad blocks, etc.. This will confirm if your
device really has memory behind the addressable blocks, as every block
will contain a unique pattern that the USB device firmware won't be able
to fake.
When done, you'll probably want to fill the device with zeros (e.g.
erase it).
Rather than userland tools and a Bourne shell script, I'd suggest doing
it in C or some other systems programming/ scripting language.
On 07/08/2015 11:14 AM, Kaza Kore wrote:
It's not a full testing of a flash device I'm
worried about,
especially as they are new, I just want to know they really are the
size they report as being...
You could use the above idea to check every 2**N blocks plus the last
block, or some other sampling of the addressable space. This could be
much faster than checking every single block (especially with large
and/or USB 2.0 and slower devices).
David