Tech Blog‎ > ‎

Wipe the Hard Drive Clean

lähettänyt Jukka Niiranen 24.10.2010 klo 23.11   [ 25.10.2010 klo 0.17 päivitetty ]
- 25. Oct 2010 -

There are times when you really need to wipe your computer's hard drive clean to avoid giving out secret information. For example before sending a computer to a repair service or before selling old hardware. We have to remember that deleting the files and folders doesn't really remove the files and all information; texts, pictures, databases, can be restores really really easily! Wiping the hard drive properly needs numerous overwriting operations for all data.

There are several commercial solutions available for this (like: Blancco). But it can also be done quite easily free of charge. This method is often preferred by individuals and SME companies.

Here are the steps needed to delete all information permanently from your hard drive. This is not a detailed "how-to", I'll add links to good "how-to"s to the end of this post.

  1. You need a bootable linux CD/DVD media. You can get one for example from Ubuntu. Just download and burn CD/DVD.

  2. Remove all other hard drives, memory cards and usb sticks from the computer. Leave only the hard drive to be emptied attached.

  3. Start your computer from the CD/DVD you created earlier. If asked choose "Test Linux" instead of "Install".

  4. Open a console window

  5. Now you can use command shred to overwrite all your data. Just type:

    sudo shred -v -z -n 7 /dev/sda

    Note: after hitting enter all your data will be lost! The number "7" indicates the number of times the data is overwritten. Overwriting will include different data patterns and the argument "-z" will add a final overwrite with zeros to hide shredding. Depending on the speed of your system and size of the disk the operation is going to take from several hours to several days. Nowadays it is considered rather safe if the number of overwriting is set to about 21-23 times. But let's be realistic, it's going to take a lot of money to restore data even after 7 over writes. The end of the command "/dev/sda" indicates which drive is to be wiped clean and this might thus differ in your case. You can read more by typing the following to the console window:

    man shred

  6. Now wait, you can follow the process from the screen. When operation stops you can just switch off the computer. If you then remove the CD/DVD and try to start the machine, you'll notice that the hard drive disk is empty and you'll get "non system disk" or similar error.

  7. Additional notes: (most likely you'll not need to worry about these)
    In some cases you'll have to unmount (detach) the file systems on the hard drive(s) before you can wipe them clean with shred. That can be done by typing:

    sudo umount /dev/sda1

    This must be done to all file systems, thus "/dev/sdb1" and so on.

    In some cases, the shredding turns out to be very very slow. (Note, that even in fast systems shredding is going to take several hours in any case!) But in some extreme cases there might be something wrong with the drive parameters and you can try the command below.

    hdparm -X66 -d1 -u1 -m16 -c3 /dev/hda

    In any case this applies to very old systems and old linux distributions, so you should not nowadays come across with this. And again the end "/dev/hda" might vary depending on your drives. Read more by typing:

    man hdparm

  8. After the wiping / shredding I've usually installed a clean Ubuntu Linux to all hard drives to a) hide the shredding and b) to see that the old hardware didn't broke due to the hours of work the wiping took. To do this put in the Ubuntu CD/DVD you downloaded, start the machine up and when asked click "Install". Follow the quick and easy steps shown on the screen and when the installation is ready (installation is really really easy) take the CD/DVD out and boot the computer. Everything should be fine now. One additional useful command I've noticed is:

    sudo touch /forcefsck

    Which forces the system to do a file system check during the next boot up and provides you with some more confidence about the well being of the drive. However If you really have doubts about the health of your hard drive I'd suggest that you download a hard drive testing software from your hard drive vendor's web site.

Links to other sites about this: