Small Printed Circuit Board

Code, Docs & Tools

Totally erase a disk using dd

dd

There are many ways to totally erase a disk, using different commands or dedicated tools.

dd is just one of them: since dd is a common command on Linux, it is probably one of the better and easier solutions.

BE CAREFUL: executing this command won't ask you any confirmation, so please select the target device very very carefully!

To erase entire disks, you have to execute this command with root permissions (or using sudo).

# dd if=/dev/urandom of=/dev/sdX bs=4096

In the above example, the target disk is /dev/sdX. The disk is totally overwritten using random data from /dev/urandom. Alternatively you can set the data source as /dev/zero to fill the device with zeroes: anyway, the random data is a better and more secure choice.

Extra security

If you need to be sure that the data is totally erased from the disk without chance to be recovered, you have to execute the same command at least 4-5 times.

Executing it more times won't hurt, and it further reduces the chance to recover the data.