Using the /dev/zero to erase an HDD is very slow, so I'm going to use a prepared file of 1GB with random or zeros.

But how can I loop this File with dd?

dd if=loopfile of /dev/sdx 

/dev/zero is not slow at all, maybe all you need is dd bs=1M. Should do several gigabytes per second, so the HDD/SSD is the bottleneck.

# dd bs=1M status=progress if=/dev/zero of=/dev/null
234309550080 bytes (234 GB, 218 GiB) copied, 11 s, 21.3 GB/s

Or just go with shred.

# shred -v -n 1 /dev/eraseme

That should go with (pseudo)random data at full HDD speed. If it must be zero then -n 0 -z but with shred it won't be any faster than random data.

  • Now I use the shred command. dd with zeros need 240h, shred only 24h. – ThomasDr Apr 23 '17 at 12:33

The problem here for you is that the default blocksize for dd is 512 bytes, so that's two system calls and two requests for IO per KB. You've got two million of those per GB; no wonder it's slow.

  • Don't use dd. Use cat (it's far faster in many situations and rarely, if ever, slower):

    cat /dev/zero >/dev/sdX
  • If you really must use dd, increase the blocksize to something rational:

    dd if=/dev/zero bs=32M of=/dev/sdX
  • If you're trying to erase the disk with pseudo-random data, consider DBAN with a single pass. (Don't bother with multi-pass; either one pass is sufficient or you need a hammer.)

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.