How to erase hard drive securely

When it gets to the time to return your server to your provider, you need to securely remove your files from your server before returning your server, specially if you have sensitive data in there and you do not want the next person who gets the server to be able to access your data using data recovery tools.

Some software packages provide tools to zero write the entire disk after removing your files to make it impossible to recover your data, however if you are looking for a simple option, you can write your own shell script to do it for you by copying a dummy file over and over on a folder in your server until your disk gets full.

This tutorial explains how to erase hard drive securely on a Linux machine, if you are using a Windows, you can create a batch file using similar commands.

1. Backup all of your data, there is no way back so ensure that you have backed up all of your files.

2. Next step is to remove your data including your database files and any sort of sensitive information you may have. You may format your hard disk if you have access to it and then start the following task after formatting your disk, otherwise you can remove all of your files, databases, configuration files, SSH private and public keys ( /root/.ssh folder).

3. Create a dummy file so we can copy it over and over to fill the entire disk, to create a dummy file, you can use the following bash script:

cd /
nano copy.sh

And copy the following in the file:

for i in {0..10000000}
do
echo '0000000000' >> dummy
done
for a in {1..1000000}
do
cp dummy $a
done

Hit Ctrl+o , Press Enter key and then press Ctrl+x to exit.

Run the following command to generate the dummy file:

sh copy.sh &

Now you can logout and the server should copy the dummy file to fill the disk. Depending the disk size and processor speed, the time it takes to complete this process may vary. On an Intel quad core processor it took me about 2 hours to finish the task on a 1TB hard disk.

2 Responses to How to erase hard drive securely

There are some advantages to using paid software to wipe server data.
1) Some companies require you to use certified software. The EAL 4+ certification means the software was tested by the NSA and that data deleted using such software has been shown to be irrecoverable even with advanced forensic methods. This also ensures the software is compliant with standards such as HIPAA or Sarbanes-Oxley.
2) The right software provides secure audit logs and reporting. This helps protect the company by allowing you to track erasures and ensure procedures are followed properly.
3) The right software allows you to select your wipe pattern such as the DoD 5220.22-M. Again, some companies require you wipe using a specific pattern.
4) Special options may be available like the ability to wipe remotely or to wipe large arrays of disks simultaneously.

In situations where the above considerations are not an issue, writing your own script may be sufficient. Otherwise, I’d recommend using certified software to erase hard drive data like WipeDrive Enterprise.

I agree with Sam. I started having problems when I would format my own computer to delete the data. It was still recoverable. I recommend WipeDrive if you want your personal data completely deleted off of your hard drive. It has worked out well for me and I’ve never had any problems with it.