How long should dd take to zero a partition

Written by James McDonald

October 13, 2008

I had a virus infested computer and I wanted to zero the partition and restore from a partimage file but first I thought I would zero out the data on the partition using dd so:

dd if=/dev/zero of=/dev/hda1

This took absolutely ages… and I was wondering when it was going to finish.

To get dd to give you a progress update

ps -ef | grep dd
kill -USR1 pidofdd

You will get the reply of something like:

68863229+0 records in
68863229+0 records out
35257973248 bytes (35 GB) copied, 4383.96 seconds, 8.0 MB/s
72871543+0 records in
72871543+0 records out
37310230016 bytes (37 GB) copied, 4655 seconds, 8.0 MB/s

The above is after running kill -USR1 pidofdd twice

So at the above rate the 40GB+ will take almost an hour and a half to zero out.

2 Comments

  1. Kirk M. Schafer

    You can vastly increase throughput by using a blocksize, e.g., for a SATA drive:

    # dd if=/dev/zero of=/dev/sdb3
    returns a throughput of 9MB/s, but:
    # dd bs=8K if=/dev/zero of=/dev/sdb3
    results in a throughput of 65MB/s

    Throughput will decline over time (as circumference changes and the data pipe is saturated), but the average will be *much* higher than simply doing a byte-by-byte transfer, because there’s a lot less overhead and hard drives are designed to take blocks of data. Other performance methods are possible (a bit out of scope, but I’ll touch on them quickly): hdparm and sdparm (the former can still be used in a limited fashion on SCSI (SATA) devices) examine/tweak parameters that increase the performance of your operation, such as the data block size the drive accepts. In my case, zeroing a drive as I write this comment, that was 8192, or 8K, which is why I used it as an example.

    As a final hint for the benefit of visitors, hdparm provides a “test” function:
    # hdparm -tT /dev/sdc
    which allows a person to determine if the tweaks they’re using are effective. The specific tweaks are unique to the system, documented with an easy Google search, and necessarily left as an exercise.

    Reply
  2. admin

    Thanks for this Kirk… Waiting around for dd to finish is a chore so anything that can be done to increase throughput is welcome. I vote your comment “Comment of the Week”

    Reply

Leave a Reply to Kirk M. Schafer Cancel reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…