1

I recently bought some USB sticks and SD cards. The price was way too good, and I suspect they are counterfeit products. I am not able to find a program to that runs on Ubuntu that can be used to check these cards/sticks. I do not have the skills necessary to compile, so I would like a program that will install easily. Thanks.

amc
  • 7,292
wjbite
  • 21

3 Answers3

1

What you need to test basically is that the drive can hold the advertised amount of data and "remember" it for later use.

A very simple approach would be to generate a file with random content and the same size as the drive as your test data, write to the drive to test and finally compare the written data with the original file. This requires quite a bit of intermediate storage space and we can do better by just storing an initialization vector for a random number generator. This is what I'll describe below.

I'll assume that the drive to test is located at /dev/sdx and advertises a total size of 32 GiB = 32768 MiB throughout this question.

  1. Install the openssl package if you don't have it yet:

    sudo apt install openssl
    
  2. Generate a random initialization vector (IV) for the generation of the test data stream:

    openssl rand 32 > ~/template-iv.bin
    
  3. Write a (pseudo-)random data stream onto the drive until it's full:

    dd if=/dev/zero bs=1M count=32768 2>/dev/null | sudo openssl enc -rc4 -nosalt -out /dev/sdx -pass pass:~/template-iv.bin
    

    (Replace the 32768 in count=32768 with the size of you drive in Mibibytes.)

    If you specified the correct size for the drive and there are any messages about I/O errors the drive is faulty.

  4. Compare the data on the drive with the same (pseudo-)random data stream:

    sudo dd if=/dev/sdx bs=1M iflag=direct | cmp - <(dd if=/dev/zero bs=1M count=32768 2>/dev/null | openssl enc -rc4 -nosalt -pass pass:~/template-iv.bin)
    

    (Replace count=32768 like before.)

    There should be 3 lines of status output from the first dd command. If there are any messages about I/O errors or comparison mismatches the drive is faulty.

David Foerster
  • 36,890
  • 56
  • 97
  • 151
1

There's a Linux program called F3 which can test for fake flash drives. The info and download are at http://oss.digirati.com.br/f3/. It's not a big deal to compile, as it only requires the use of the make command in terminal. The program is actually two separate programs, f3write and f3read.

Use them in terminal, like this:

cd directory_where_f3_source_is_located ie: cd ~/Desktop/f3

make used to compile the program, only required once

./f3write /path_to_flash_drive ie: ./f3write /media/my_username/my_flash

./f3read /path_to_flash_drive ie: ./f3read /media/my_username/my_flash

A video can be viewed at https://www.youtube.com/watch?v=qnezKfCTO7E

heynnema
  • 73,649
0
sudo dd if=/dev/zero of=/dev/sdb

This will fill the entire drive, assuming it shows up as /dev/sdb, with zeros. It will report if there are any errors, and the transfer rate when it finishes, as well as how much data it actually wrote. If there are no errors and the size matches what you expect, it is probably not counterfit.

For a more thorough test using non zero data, you might look at badblocks.

psusi
  • 38,031