Will formatting my drive TRIM my SSD?

5,844

Solution 1

TRIM is a command that needs to be sent for individual blocks. I have asked the question before (What is the recommended way to empty a SSD?) and it is suggested to use ATA Secure Erase, a command that is sent to the device to clear all data.

Solution 2

mkfs.ext4 has an extra option -E discard to send TRIM for appropriate blocks when creating the filesystem.

I can't tell whether the installer uses this option, or whether it is used by mkfs.ext4 by default, but at least you can explicitly use it when creating the filesystems on your own.

Solution 3

Quick steps and results (summarised from the ATA Secure Erase page) follow: If the output is not what is expected, see the full page. Replace /dev/X with your device.

  1. hdparm -I /dev/X should include "not frozen" - if frozen (see notes below on what went wrong for me):
    • Suspend the computer, complete the rest of these steps then power off (see notes)
    • or try printf mem > /sys/power/state (from the comments; didn't work for me - permission denied)
  2. hdparm --user-master u --security-set-pass password /dev/X
  3. hdparm -I /dev/X should include "enabled"
  4. hdparm --user-master u --security-erase password /dev/X
  5. hdparm -I /dev/X should include "not enabled"

From the page's results, it seems that these steps should be able to be done in a couple of minutes on an Intel X25-M 80GB SSD. Correction: On my Intel X25-M, I was done in just over a minute: step 2 is instant.

Notes on unfreezing via suspend: Suspending my computer to unfreeze the disk worked for me. I:

  1. installed Ubuntu
  2. booted it
  3. added graphics drivers
  4. Rebooted - but it froze on shutdown
  5. Reset power, and found an unbootable system.

Re-launching the install showed that there were no partitions on my drive. It seems that bypassing the BIOS security left my partitions in memory of some kind.

Share:
5,844

Related videos on Youtube

Stephen
Author by

Stephen

Updated on September 18, 2022

Comments

  • Stephen
    Stephen over 1 year

    Will a standard fresh linux (Ubuntu 11.10 to be exact) install and drive re-format (full) successfully TRIM my SSD, or do I need to do something extra?

    I know that ext4 will TRIM blocks on erase when I specify the discard option, but I want to start with a completely TRIMmed drive if possible.

  • clerksx
    clerksx about 12 years
    If it's frozen, you may want to try unfreezing it by suspending the system to memory. printf mem > /sys/power/state usually does the trick.
  • TvE
    TvE about 5 years
    In man mkfs.ext4 it says "discard: Attempt to discard blocks at mkfs time [...] This is set as default." There is also a nodiscard option.