Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Secure Erase A Drive

I am just about to reinstall Ubuntu 12.04 onto an SSD that I have been using as an extra data storage drive. Before installing the OS onto an SSD, it may be a good idea to "reset" it to peak performance by performing a Secure Erase operation.

The first thing we need to do is determine what the drive letter is of the drive we want to reset. E.g. sda, sdb, or sdc.

Use the command below to list what drives we have (ignore numbers as they represent partitions)

ls /dev/sd*

Use the command below to fetch all the information about a drive.

sudo hdparm -I /dev/sdX

Below is a quick way just to get the size of the drive:

sudo hdparm -I /dev/sdX | grep "device size"

Below is a quick way just to get the model of a drive:

sudo hdparm -I /dev/sdX | grep "Model Number"

Run The Erasure

Once you are confident that you know the letter of the drive that you want to erase (e.g. something like "sdc"), then we can start the erase procedure.

sudo hdparm --user-master u --security-set-pass my-password /dev/sdX
sudo hdparm --user-master u --security-erase my-password /dev/sdX

Make sure none of the drives partitions are not mounted before running these commands!

If you get an error message along the lines of "bad sense data", please check that your drive isn't "frozen". It should appear as "not frozen" when you run sudo hdparm -i /dev/sdX. To unfreeze a drive, you may need to reboot, or try re-plugging in the drive whilst the system is running (requires AHCI).