Thursday, January 31, 2013

Destroying a Disk

http://www.noah.org/wiki/Dd_-_Destroyer_of_Disks
Is wrong when he dismisses the need for more than overwriting a file with zeros 
but he is correct that this is slow:
dd if=/dev/urandom of=/dev/drive-to-destory
so here is a faster way to lay down a more or less random bit pattern on a drive partition:

disk=$1
dd  bs=1K count=1000 if=/dev/urandom of=/tmp/randomJunk$$
{ while : ; do cat /tmp/randomJunk ; done; } | sudo dd bs=1M of=${disk}
rm /tmp/randomJunk$$


It takes a bit to generate the 1M file from /dev/urandom but the overwrite of the partition goes well.

If you want to be sure the disk is still usable, you want to erase the existing partition table and 
then create one full disk partition. Use the script above to overwrite the new partition. 
This preserves the MBR and other stuff at the front of the drive.

No comments:

Post a Comment