0

To clear a large hard drive I was using dd if=/dev/zero of=/dev/sda. Only later I realized from reading more sources that the default block size is 512, and if I want the process to go quicker I should increase the block size to at least 4M.

My question is what happens if I cancel before it finishes (ctrl + c or quitting terminal would cancel it hopefully?). Am I able to redo the command and set a higher bs? Or would the system basically be corrupted at this point and I wouldn't even be able to log back in? If I can still redo it at this point, what would be the highest bs value I can use for a 1TB drive (software raid 1 if it matters)?

user182417
  • 11
  • 1
  • 2
    Why not try it? You're wiping the system anyway, why does it matter if it gets corrupted? You should be doing this from a Live CD/USB image though. – gparent Jul 21 '13 at 01:05
  • [This](http://superuser.com/questions/586776/what-happens-if-i-dd-zeros-to-the-drive-where-dd-resides) happened when I run dd on a live OS. – Hennes Jul 21 '13 at 13:15

2 Answers2

3

Corruption is a funny thing when you're overwriting a hard drive. You should assume that your disk is corrupted after the first few blocks have gone through (meaning <1 second). Your end goal here is to completely rewrite every byte on the disk with 0x00, right? Whether a specific byte is written once, or twice, or 30 times, at the end of the day it's still 0x00 and your data is effectively unrecoverable.

Scott Pack
  • 14,907
  • 10
  • 53
  • 83
2

If your OS is not on /dev/sda then of course you can cancel it.

If your OS is on the dfisk you are wiping then it depends. E.g.

  • How long was the dd command running?
  • Which OS/distribution did you use? Are things cached and seemingly available even though the underlying information on the disk is already destroyed?

And finally, why try to run this from inside the OS? Normally I would either boot from another disk (e.g. a liveCD or a liveOS on a pendrive), or I would send the disk the command to erase itself without any OS intervention. This is done with the secure erase command. You can issue this command with the hdparm tool.

First use hdparm -I /dev/sda to check that the drive is not frozen.

Then set a password:
hdparm --user-master u --security-set-pass Mypasswordhere /dev/sda

Finally issue the secure erase command:
hdparm --user-master u --security-erase Mypasswordhere /dev/sda

If you need to do this to many computers, try Darik's Boot And Nuke disk.

Hennes
  • 4,842
  • 1
  • 19
  • 29