LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
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?

Notices


Reply
  Search this Thread
Old 02-02-2010, 07:05 AM   #1
suse_nerd
Member
 
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!

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

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Make a big file with dd
Code:
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:
Code:
mv abigfile original
copy the file back from the stick
and compare it to the original
Code:
diff original abigfile
That do it for you?
 
Old 02-02-2010, 08:25 AM   #4
suse_nerd
Member
 
Registered: May 2008
Distribution: SuSe
Posts: 50

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

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

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


  exit 0
fi

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.
 
  


Reply

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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 05:11 PM.

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