Cleaning SSDs, the fast way


The ATA Specification knows an option 'Secure Erase'.

To do this, do the following:

boot from a live linux.


Read every output very carefully so you don't choose the wrong device!
All commands are executed as root, be carefull!


Find out what model you have and determine the size.

Identify the the right device:

   hwinfo --disk | grep -E 'Model|Device File:'

      Model: "KINGSTON SKC400S"
      Device File: /dev/sda
      Model: "ST2000NX0403"
      Device File: /dev/sdb
      Model: "ASMT 2105"
      Device File: /dev/sdc (/dev/sg3)

or

   lshw -short |grep disk

      /0/100/1c.1/0/1/1/0.0.0  /dev/sdc      disk           108GB 2105
      /0/100/1f.2/0                 /dev/sda      disk           1024GB KINGSTON SKC400S
      /0/100/1f.2/1                 /dev/sdb      disk           2TB ST2000NX0403
      /0/100/1f.2/0.0.0           /dev/cdrom  disk           DVD-RW  DVR-219L

(i used the ASMT-device, USB to SATA adapter successfully)

Get number of 'sectors'

   hdparm -N /dev/sdc

      /dev/sdc:
       max sectors   = 210997484/234441648, HPA is enabled

The 'Host Protected Area' can be used for 'Overprovisioning'
This device has HPA enabled.

For erasing the device you have to set a password:

   hdparm --user-master u --security-set-pass EINS /dev/sdc

Erase the entire disk:

   time hdparm --user-master u --security-erase EINS /dev/sdc

The 'time' comand will give you the elapsed time for this operation,
the option '--security-erase' will erase the entire device.

If a HPA is not defined you can  do this with next command.
to define the HPA for Overprovisioning, set it to 10 percent:

   hdparm -Np210997484 --yes-i-know-what-i-am-doing /dev/sdc

You can disable the HPA:

   hdparm -Np1000215216 --yes-i-know-what-i-am-doing /dev/sdc

I used a HPA of 10 percent, most of the manufacturers use 7 percent.

helpfull links:
Thomas Krenn - Perform a SSD Secure Erase
Wikipedia: Host protected area
Kingston - Overprovisioning

I never tried that with NVME devices and UEFI setup! Please report.