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.

1

3 Answers 3

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

1
  • Oh, nice. I heard about that before but thought it was Windows-only. I recommend editing this answer to expand it with specific details about how to install and use this. Oct 30, 2016 at 17:16
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.

3
  • You might look at the Linux program F3. More info in my answer.
    – heynnema
    Oct 30, 2016 at 15:58
  • You specified /dev/loop0 instead of /dev/sdx, but otherwise a very good solution to detect wraparound.
    – psusi
    Oct 30, 2016 at 17:25
  • @psusi: Thanks for the hint. I tested it with a loop device since I didn't have an unused drive handy. Oct 30, 2016 at 23:37
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.

2
  • That's not enough unfortunately. Some counterfeit storage media "wrap around" when you try to write beyond their actual size limit. Neither the above dd command nor badblocks can detect that. Oct 30, 2016 at 10:07
  • @DavidFoerster, interesting... I had only heard about cases where they fail to write beyond their real size.
    – psusi
    Oct 30, 2016 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .