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!

The reason I am not using hdparm --secure-erase PASS /dev/sdX is because I did not want to have to go into detail about checking if a drive is frozen and how to "wake up" the drive. However, in the end, this did not work for me, and the only way I could unfreeze my Samsung 840 drive was to suspend my computer before waking up again. Unplugging the drive and plugging it back in again appears to not work in Ubuntu 12.04 with H87 chipset (AHCI enabled).

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus