What is the dd command in Linux for securely wiping sector 62 of a hard drive. This sector lies in track zero, begins at offset 31744 and is 512 bytes long.

I'd like to know how to wipe it over 1000 times with ultra random data and then wipe over it say 100 times with zeros.

My computer has only one hard drive and I'll be doing this from an Ubuntu live CD using the terminal.

  • 2
    Backup anything you don't want to wipe out, then nuke the HDD from the orbit. It's the only way to be sure. (Sorry, could not resist.) – delnan Jun 26 '11 at 9:42
  • 1
    Wow, that's 512 bytes you really want to make go away. I wonder what they are. – Lukasa Jun 26 '11 at 9:58
  • Whatever they are, they have three separate single-question accounts asking this same question one, two, three times within the past couple of days alone. – JdeBP Jun 26 '11 at 13:56
  • This wasn't posted on superuser but on stackoverflow and migrated here... I am not a single question account im registered with stack exchange. – Daniel Gratz Jun 26 '11 at 16:45

run the following command however times you want: warning: this has its share of risk of damaging your valuable files & data. don't run unless you understand it...

$ sudo su [enter]
# dd if=/dev/random of=/dev/sda bs=512 count=1 seek=62 [enter]
# dd if=/dev/zero of=/dev/sda bs=512 count=1 seek=62 [enter]

note that

repeat [times] [command]

would repeat the command [command] for [times].

substitute urandom with random if you want more randomness
substitute random with urandom if you want more speed

add the zeroing back

  • Thanks. So repeat 1000 dd if=/dev/random of=/dev/sda bs=512 count=1 seek=62 is correct? I would have thought i'd have to specify the offset not just 62. But if it understand that it is 62nd sector then i guess it is ok, but it would be a disaster if sector 63 got deleted. Of course this is relative to the physical hdd not logical. – Daniel Gratz Jun 26 '11 at 10:08
  • you just install grub again if you have such problem (or, plug in the windows installer disc and repair the bootloader) – bubu Jun 26 '11 at 10:09
  • It worked, however the 'repeat' command was 'not found'. So basically i don't know how to loop it a desired number of times... – Daniel Gratz Jun 26 '11 at 17:11
  • for I in {1..100}; do dd if=/dev/zero of=/dev/sda bs=512 count=1 seek=62; done – Daniel Gratz Jun 26 '11 at 18:28
  • IIRC repeat is a c shell command – bubu Jun 27 '11 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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