Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 02-02-2010, 07:05 AM   #1
Registered: May 2008
Distribution: SuSe
Posts: 50

Rep: Reputation: 15
Fake USB stick testing tool?

I am looking for a tool or command to test a USB pen drive.

This would typically involve outputting 8GB or 4GB of data from /dev/random (for example) to the pen drive, then reading it back and checking that 4GB/8GB is read back correctly or if in fact there is any errors when writing.

Does such a command exist or can it be made?

Perhaps using dd or something similar.

I know Windows utilities exist, so it must be possible on linux!

Old 02-02-2010, 08:06 AM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
Why not create such a file, and using md5sum on it before and after copying it to the pendrive.
Old 02-02-2010, 08:11 AM   #3
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Debian "Testing"
Posts: 6,111

Rep: Reputation: 413Reputation: 413Reputation: 413Reputation: 413Reputation: 413
Make a big file with dd
dd if=/dev/random of=abigfile bs=1024 count=4096K
(this may take sme time)
copy the file to the stick
rename your original file:
mv abigfile original
copy the file back from the stick
and compare it to the original
diff original abigfile
That do it for you?
Old 02-02-2010, 08:25 AM   #4
Registered: May 2008
Distribution: SuSe
Posts: 50

Original Poster
Rep: Reputation: 15
Yeah I think something like this would work

#Pass arguments
# $1=path to flash drive
# $2=size of file

if [ $# -lt "$MINPARAMS" ]
  echo "This script needs at least $MINPARAMS command-line arguments!"
  echo "Usage: /location/to/mounted_drive size_of_file_in_GB"
  echo "Example /mnt/disk 2"

  exit 0

echo "Flash drive is at " $1
echo "Testing " $2 " file"

#Calculate block count
VAR=$(( $2 * 1000 ))

#Calculate checksum for desired file size from /dev/zero (no data is put on HD)
echo "Checksum should be: "
dd if=/dev/zero bs=1MB count=`echo $VAR` | md5sum

#Really copy the file to the flash drive and calculate a checkum on the flash drive file
echo "Checksum on copying to flash drive is..."
dd if=/dev/zero of=`echo $1`/testfile bs=1MB count=`echo $VAR` 
md5sum `echo $1`/testfile

#Calculate checksum of file after copying it from flash to hard drive (no data is put on HD)
echo "Checksum on copying back is..."
dd if=`echo $1`/testfile  bs=1MB count=`echo $VAR` | md5sum
Edit: The above seems to work.

Last edited by suse_nerd; 02-03-2010 at 10:25 AM.


capacity, check, disk, drive, fake, pen, stick, usb

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to fake usb connection ? jabka Linux - Hardware 1 09-20-2007 08:08 PM
tool for testing HDD saavik Linux - Hardware 3 02-01-2006 07:53 AM
FAKE APT-GET OR YUM resources ???cracker spoof stick ? my-unix-dream Linux - Newbie 2 05-14-2005 12:04 PM
mount/umount usb stick - PQI Intelligent Stick 2.0 sandbag Linux - Software 5 05-06-2005 11:12 AM
Using knoppix as a testing tool on a laptop. dr_zayus69 Linux - Software 3 03-29-2005 08:29 AM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 01:03 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration