Wiping HDD

I just sold my older notebook on Mercado Livre (amazing how it devalued from R$ 2700.00 to R$ 700.00 in just 3 years).

Something I consider important before selling a notebook is to delete all personal files, confidential files, saved passwords, and any other information that could harm you if it falls into the wrong hands. A good solution would be to format the disk, right? Wrong.

Unless the disk is encrypted, formatting is not enough. After a regular format, the blocks that contained content are simply marked as available in the address table, meaning the data remains on the disk and can be recovered using a specific tool, like extundelete which I wrote about in another article.

The most efficient way to completely clean the disk and make the data irrecoverable without causing damage to the disk is the technique known as disk wiping using a disk scrubbing, which basically overwrites the entire disk with zeros and/or ones.

The most traditional and simple method to perform disk scrubbing on Unix systems is to use dd or cat.

  1. Boot from a live disk

  2. Optionally delete all partitions with gparted or fdisk

  3. Check badblocks with badblocks or fsck:

    badblocks -wvs /dev/sda
    fsck -f /dev/sda
    

    I believe that using -w with badblocks is already sufficient to prevent data recovery from the disk, as it writes multiple times to all blocks on the disk. To make the program repeat the check multiple times, use the -p option. The process takes a few hours, one way to speed it up is to increase the number of blocks tested at a time with the -c option.

  4. Use one of the following methods, repeating as many times as necessary

    2 times should be sufficient, unless the disk is being analyzed by very determined experts.

    • Method 1

      Write zeros to the entire disk: dd if=/dev/zero of=/dev/sda

    • Method 2

      Write random zeros and ones (recommended): dd if=/dev/urandom of=/dev/sda

    • Method 3

      Same function as the previous commands, but using cat. Writes random bits twice and zeros the third time.

      cat /dev/urandom > /dev/sda;
      cat /dev/urandom > /dev/sda;
      cat /dev/zero > /dev/sda
      

      On a 250GB HD, I ran it with some messages to have an idea of time, but even after 10h it didn’t finish on the first run:

      echo "Inicio em `date`";
      
      cat /dev/urandom > /dev/sda;
      echo "Escrita #1 finalizada em `date`";
      
      cat /dev/urandom > /dev/sda;
      echo "Escrita #2 finalizada em `date`";
      
      cat /dev/zero > /dev/sda;
      echo "Escrita #3 finalizada em `date`"
      

      Therefore, I think it’s better to use a program that shows progress.

    • Method 4

      Shred: Already installed on several distributions. Example of usage: shred -n 3 -z -v /dev/sda.

    • Method 5

      Download another program. There are several free software programs specifically for this purpose that write zeros and ones to the entire disk and automatically repeat the process several times.

      In a quick search, I found the following programs: Dban, Autoclave, Wipe, KillDisk.

      Apparently, the most commonly used for this purpose is DBAN, an 11MB boot disk that can be downloaded at http://www.dban.org/.

      The process is a bit time-consuming and depends on the HD, on average it should take around 2 minutes per GB.


Julio Batista Silva
Julio Batista Silva
Data Engineer

I’m a computer engineer passionate about science, technology, photography, and languages. Currently working as a Data Engineer in Germany.

comments powered by Disqus