Best way to zero out a drive?

Discussion in 'all things UNIX' started by EncryptedBytes, Feb 20, 2011.

Thread Status:
Not open for further replies.
  1. EncryptedBytes

    EncryptedBytes Registered Member

    Joined:
    Feb 20, 2011
    Posts:
    449
    Location:
    N/A
    I need to turn in an old hard drive, however I prefer to zero it out instead of simply reformatting/nuking it with some third party software. Is this still the most effective DD command on ubuntu based distros:

    Code:
    dd if=/dev/zero of=/dev/sdb
    where sdb is the drive I want zero. Or is there more to the command to make sure every bit of the drive gets written as 0o_O?
     
  2. Ocky

    Ocky Registered Member

    Joined:
    May 6, 2006
    Posts:
    2,677
    Location:
    George, S.Africa
    Last edited: Feb 20, 2011
  3. Escalader

    Escalader Registered Member

    Joined:
    Dec 12, 2005
    Posts:
    3,710
    Location:
    Land of the Mooses
    What do you mean turn in?

    Give drive to somebody else only zero'd?

    Best way is not to do it at all. Use a blowtorch or sulphuric acid or a giant magnet.

    Or give it to my grandsons they can fill it with games that should do it?

    Just kidding of course.:D
     
  4. TheKid7

    TheKid7 Registered Member

    Joined:
    Jul 22, 2006
    Posts:
    3,469
  5. NGRhodes

    NGRhodes Registered Member

    Joined:
    Jun 23, 2003
    Posts:
    2,331
    Location:
    West Yorkshire, UK
  6. chronomatic

    chronomatic Registered Member

    Joined:
    Apr 9, 2009
    Posts:
    1,343
    OP,

    The command you provided in your first post is the command you will want to use for zeros. It is also about the fastest method for drive wiping available. One pass is enough to render data unrecoverable.
     
  7. katio

    katio Guest

    append:
    bs=20480
    to the dd command
    It's faster, at least for my drives.


    If you want to see the progress, sort of, without mocking around with additional programs and pipes:
    open another terminal
    get the pid of dd (with top, ps, pgrep, whatever you have available),
    assuming the pid was 1234 type:
    sudo kill -usr1 1234

    If you wanted to use the drive again for yourself you could use badblocks instead. It can write 0, 1, a pattern of your choice or very fast pseudorandom data onto the drive, then it reads all sectors and checks if they have the correct value (the one you've just written to it). So besides overwriting everything it's also a very thorough health test.
    e.g.: badblocks -wvs /dev/sdb for destructive overwriting
    check the man page for more options

    hdparm is also an useful utility, however be warned, read the man page carefully, it's very powerful and can destroy the hdd (or another if you mistype a single letter... general advice: it's best to unplug all drives except the one you are wiping)
    but it can show you for example if there are any hidden partitions, Host Protected Area (HPA)
    e.g.: hdparm -N /dev/sdb to check if there's a HPA...
    and hdparm -I /dev/sdb for verbose information
     
  8. EncryptedBytes

    EncryptedBytes Registered Member

    Joined:
    Feb 20, 2011
    Posts:
    449
    Location:
    N/A
    Thanks everyone for the advice and tips!:cool:
     
  9. mack_guy911

    mack_guy911 Registered Member

    Joined:
    Mar 21, 2007
    Posts:
    2,677
    Last edited: Feb 22, 2011
Loading...
Thread Status:
Not open for further replies.