Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a hard drive that went bad and before I send it for RMA I want to wipe as much as possible from it. I tried using windows utilities and also did dd of /dev/random. The problem is I can't wait for either of those solutions to finish as the reason for the RMA is that it writes at a max speed of 1 MB/Sec. It will take over 140 hours just to do a single pass of the 500GB hard drive.

I have been looking for a utility (or even a bash script on linux) that would pick sectors at random and write random data (or even zeros) to those sectors. I'm hoping that if I run this for 24 hours, that will wipe approximately 80 GB of data. Since it will be randomly chosen, all the bigger files will be impossible to recover and the smaller ones will either be wiped, will be missing chunks, or will possibly be recoverable. This is unfortunately the optimal solution for me at this point.

SOLUTION

Thanks to "evildead" I was able to get a lot of the data on the drive to be randomly filled with junk from /dev/urandom. The bash script, in case someone ever needs it, is below:

#!/bin/bash
while (true); do
    randnum=${RANDOM}${RANDOM}
    number=$((10#$randnum%976773168))
    echo -e $number >> progress.txt
    dd if=/dev/urandom of=/dev/sdx1 skip=$number count=1
done

You will need to replace 976773168 with the number of blocks on your drive. I originally tried $RANDOM in bash, but it is only a 16-bit int and therefore is only 32k. As I needed a number that is over 900 Million I combined two $RANDOM values, so for instance if my random numbers are 22,861 and 11,111 I get 2,286,111,111 then fitting it to my block size I get a pretty random value in my range. It doesn't have perfect entropy but then again, what is really random on a computer? ;) The 10# is there in case the first random number is a 0, it forces bash to use base 10, not base 8, which is what it uses if it thinks the number is an octal (leading zero). I also write the random numbers to a file for analysis later to see what the spread was. If you don't need this you can just take out

echo -e $number >> progress.txt

and it will run fine. Also dont forget to replace sdx1 with the actual drive or partition you want to work on. I hope this is helpful for someone, I know it was really helpful for me.

share|improve this question

4 Answers 4

up vote 4 down vote accepted

you can use a shellscript in combination with dd.

e.g.

 while (true); do
   number=$((($RANDOM * 32768 + $RANDOM)))
   dd if=/dev/urandom of=/dev/sdx1 skip=$number count=1
 done

You only have to modify the number which is generatet from $RANDOM to fit to your Blocks.

share|improve this answer
    
Did you ever hear of software that does this? Cause I haven't and it seems like at least some people would find it useful. –  Marcin Nov 21 '09 at 20:44
    
Worked great, I made some changes to the script for my situation, I added them to my question in case someone else had to use it in the future. Thanks for your help. –  Marcin Nov 22 '09 at 10:58
    
Hi, I never had such a problem and so I never heard about any software to solves such a problen. I knew dd can skip blocks and supports limit wirtes with count. So the only problem was to get a random number and putting everything together. :) –  evildead Nov 23 '09 at 0:13

The best software that will automate this process is Darik's Boot and Nuke (aka DBAN)

It's a boot CD with a comprehensive range of drive-wiping mechanisms, ranging in aggresiveness (And time taken to wipe the drive)

It is available from http://www.dban.org/

share|improve this answer

If you have a powerful magnet, you can physically wipe it.

I take apart old, dead hard drives and get the voice coil magnets from the head positioning assembly. These are rare earth magnets, and from a typical 3.5" drive they're powerful enough to erase enough of the servo tracks on a hard drive so it'll be completely unusable.

One way or another, get the magnet, wipe it back and forth over the top cover of the drive and in less than a minute you'll have a dead drive. Since it's being RMA'd anyway, they shouldn't care.

share|improve this answer

The dban option is the correct answer to this problem.

Writing "random" data from /dev/random will run into problems on most systems because you'll exhaust the entropy on the system and wind up writing the data very slowly.

Almost as "random" as from /dev/random is to encrypt a string of zeros with a random passphrase. You can use dd and openssl to do this, and it allows you to nuke the disks as fast as the system is able to write to disk (instead of waiting on /dev/random). You'll be able to run this 3-5 times in the same time you'd run something that's just dding from /dev/random.

dd if=/dev/zero | openssl des > /dev/hda13
share|improve this answer
    
I don't understand how people constantly ignore part of the question on here. I am writing at 1 MB/Sec because the drive is broken. /dev/urandom provides data at a higher rate than that. dban is not the correct answer because it doesn't write to random sectors, it writes linearly sector by sector. It might write random DATA but it doesn't write it in a random ORDER. –  Marcin Nov 22 '09 at 20:55
    
you can use /dev/urandom or /dev/zero, doesn´t really matter. Only thing not to use is definatly /dev/random, cause it blocks if entropy is exhausted. –  evildead Nov 23 '09 at 0:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.