Hi all.
I did ask this on the Ubuntu forum roughly a week ago but have had zero helpful replies off the "community" there so I hope you don't mind the off-topic (as far as audio goes) subject here.
I have recently bought some large USB keys to use as backup storage to replace my old moving disk external hard drive. Due to the worry of the reports of fakes reporting to be large drives, even when plugged into the system, I wanted to test these before using them for real. Seems best way to do this is fill the drive up and check data for integrity.
So first step will be to create a 8GB file which I will copy multiple times. (Why 8GB? No particular reason, except it seems large enough to be useful yet small enough to be manageable. 4GB might be a better choice so it can be used with FAT32 formatted devices.)
dd if=/dev/urandon of=~/8gb block=1GB count=8
Then create a little script to copy the file across multiple times.
cp8gbx.sh
#!/bin/bash
i=0
while [ $i -le $1 ]
do
mkdir /usb_mount_path/$((i++))
dd if=~/8gb of=/usb_mount_path/$i/8gb
done
./cp8gbx.sh 15
Hopefully my thinking is correct and that, or something very similar, should copy the file 15 times, once each inside a folder called 1 to 15... Is using dd rather than cp or rsync OK here? Will it automatically wait for one copy/write to finish before starting the next? Is it worth worrying about? Can I do it with && within a script or how would you use the WAIT command otherwise in this instance?
Then to do the md5sum on each...
md5disk.sh
#!/bin/bash
i=0
while [ $i -le $1 ]
do
md5sum /usb_mount_path/$((i++))/8gb >> /usb_mount_path/md5checks
done
./md5disk.sh 15
The 15 in the examples above is assuming a 128GB drive. 8*15=120GB. Even though I have used block=1GB rather than block=1G in the creation of the random file, to create a slightly smaller file, I thought the extra space to ensure not attempting to overfill the drive could be a good idea. After all, if they are smaller than advertised I'm thinking a LOT smaller, not just a handful of GBs! I also know there is a way to automatically check if each line in the created file is the same or not and thus only give me a message if there are differences. Bonus points for pushing me in that direction ;)
I haven't actually tried or tested any of this, don't know if my syntax is wrong or if my basic thinking is flawed somewhere else. If somebody wouldn't mind having a look over, point out errors, suggest ways you might do it differently, or any other words of advice or hints it would be much appreciated.
Thanks for any pointers, Dale.