From time to time you will need to wipe a drive or partion and here are the best ways to do it.
The fastest way is to simply write a bunch of zeros to the drive so:
dd if=/dev/zero of=/dev/sda bs=1M
The more secure option is to write a bunch of random data to the drive so:
dd if=/dev/urandom of=/dev/sda bs=1M
Be advised that the second option can take HOURS to finish.
Due to the way dd works you can very easily clear your MBR using the following:
dd if=/dev/zero of=/dev/sda bs=446 count=1
the “bs” option tells dd how many bytes to write per cycle and the “count” of “1” tells dd to run a single pass (cycle).
Clearing a partition is just like clearing a complete drive except you tell dd which partition should be cleared instead of the complete drive:
dd if=/dev/zero of=/dev/sda3 bs=1M
dd if=/dev/urandom of=/dev/sda3 bs=1M
As you can see, instead of telling dd to write to “/dev/sda” we change it to “/dev/sda3”.