What is the recommended way to empty a SSD?

I've just received my new SSD since the old one died. This Intel 320 SSD supports TRIM. For testing purposes, my dealer put Windows on it, but I want to get rid of this and install Kubuntu on it.

It does not have to be a "secure wipe", I just need the empty the disk in the most healthy way. I believe that dd if=/dev/zero of=/dev/sda just fills the blocks with zeroes and thereby taking another write (correct me if I'm wrong).

I've seen the answer How to enable TRIM, but it looks like it's suited for clearing empty blocks, not wiping the disk.

hdparm seems to be the program to do it, but I'm not sure if it clears the disk OR cleans empty blocks. From its manual page:

  --trim-sector-ranges
          For  Solid State Drives (SSDs).  EXCEPTIONALLY DANGEROUS. DO NOT
          USE THIS OPTION!!  Tells the drive firmware to discard  unneeded
          data  sectors,  destroying  any  data that may have been present
          within them.  This makes those sectors available  for  immediate
          use  by  the firmware's garbage collection mechanism, to improve
          scheduling for wear-leveling of the flash  media.   This  option
          expects  one  or  more  sector range pairs immediately after the
          option: an LBA starting address, a colon, and  a  sector  count,
          with no intervening spaces.  EXCEPTIONALLY DANGEROUS. DO NOT USE
          THIS OPTION!!
          E.g.  hdparm --trim-sector-ranges 1000:4 7894:16 /dev/sdz

How can I make all blocks appear as empty using TRIM?


ATA Secure Erase

You should use the drive's security erase feature.

  1. Make sure the drive Security is not frozen. If it is, it may help to suspend and resume the computer.

    $ sudo hdparm -I /dev/sdX | grep frozen
           not     frozen 
    

    The (filtered) command output means that this drive is ”not frozen” and you can continue.

  2. Set a User Password (this password is cleared too, the exact choice does not matter).

    sudo hdparm --user-master u --security-set-pass Eins /dev/sdX
    
  3. Issue the ATA Secure Erase command

    sudo hdparm --user-master u --security-erase Eins /dev/sdX
    

Note:

  • /dev/sdX is the SSD as a block device that you want to erase.
  • Eins is the password chosen in this example.

See the ATA Secure Erase article in the Linux kernel wiki for complete instructions including troubleshooting.


util-linux 2.23 offers blkdiscard which discards data without secure-wiping them. I tested: works over SATA and mmcblk but not USB.

An excerpt from the manual page of blkdiscard(8):

NAME

blkdiscard - discard sectors on a device

SYNOPSIS

blkdiscard [-o offset] [-l length] [-s] [-v] device

DESCRIPTION

blkdiscard is used to discard device sectors. This is useful for solid-state drivers (SSDs) and thinly-provisioned storage. Unlike fstrim(8) this command is used directly on the block device.

By default, blkdiscard will discard all blocks on the device. Options may be used to modify this behavior based on range or size, as explained below.

The device argument is the pathname of the block device.

WARNING: All data in the discarded region on the device will be lost!

The command is there since Ubuntu 15.04 and OpenSUSE 13.1 (yes OpenSUSE has it 2 years ahead of Ubuntu).