PeopleMoutainPeopleSea
PeopleMoutainPeopleSea

Reputation: 1512

Test the limit of read/write cycles of a USB flash drive

I read from an wiki article (http://en.wikipedia.org/wiki/NAND_flash#Write_endurance) that says flash storage has a limit of read/write cycles (for NAND flash this limit is about 10K-100K).

My question is: Is it possible to test/find out this limit on my PC in a relatively short time (in a few hours or a few days)?

I wrote a simple script (/dev/sdb is flash disk), but since flash controller will do wear-levelling, I think this script may not work.

echo "0011223344556677" | xxd -r -p > a.bin

for ((n=0;n<1000000;n++)); do
     dd if=a.bin of=/dev/sdb
done

Upvotes: 1

Views: 2969

Answers (1)

Tim Mattison
Tim Mattison

Reputation: 152

It may be easier to do something like this to fill the device with random data:

dd if=/dev/urandom of=/dev/DEVICE bs=1M

Over and over again until the device fails.

If you want to check for single bit errors you could do the following:

  1. Fill the disk with zeroes - dd if=/dev/zero of=/dev/DEVICE bs=1M
  2. Get the SHA-1 sum of the whole disk - dd if=/dev/DEVICE | sha1sum
  3. Fill the disk with random data - dd if=/dev/urandom of=/dev/DEVICE bs=1M
  4. Repeat until the number from step 2 changes or the disk stops working

That should probably be wrapped up in a bash script to save you some time.

NOTE: I used /dev/DEVICE so nobody would accidentally copy and paste these snippets without thinking. You'll need to change it to your specific device and be very careful that you get it right!

Upvotes: 4

Related Questions