1

I am going to put a used SSD into a server to boot from it and hold the OS itself, while making a RAID1 from two other HDDs.

Since the SSD has been used, do I need to trim it beforehand and how? Or do I just shove it in the server and use it right away?

Pavel Tankov
  • 367
  • 3
  • 15

1 Answers1

1

I agree with Michael Hampton that a secure erase is in order to make any previous data inaccessible. There is a secure delete operation in the ATA spec, which can be run on Linux with hdparm --security-erase-enhanced This might just change an encryption key, which is fast but not guaranteed to discard the blocks.

Commands also exist to discard the entire block device, to remove any write amplification effect from erased data. Again for Linux, blkdiscard. There is a --secure option to also erase blocks, but as the man page notes "This requires support from the device."

Finally, just "quick" formatting a file system will make "empty" usable space. However, you don't have the security benefits of secure erase, nor the performance benefits of discarding everything. Despite continuous and periodic trim available on several operating systems, it is more optimal to unmap the entire device before a new file system is laid down. Blocks with half old data, half new data either won't be erased or have to be written somewhere else then erased.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32
  • "However, you don't have the security benefits of secure erase" I don't care about that. "Despite continuous and periodic trim available on several operating systems, the SSD doesn't know that the old data is forgotten when the new file system was laid down." But why? If I create a new partition that spans the whole disk, then "quick format" it and finally run fstrim on it (or mkfs runs it implicitly), doesn't that inform the SSD that all empty space (i.e., the whole space anyway, because it is empty) is to be discarded? – Pavel Tankov Feb 03 '18 at 17:30
  • Edited answer for the more nuanced reality that its more efficient when the entire device can be trimmed. And yes, modern operating systems default to trim. You can format and go if you don't care about wiping previous data. – John Mahowald Feb 03 '18 at 22:31
  • `hdparm --security-erase-enhanced` worked by following the link you provided. As mentioned in the article, I had to "quickly hot-(re)plug the SATA power cables" in order to put the SSDs in state "not frozen" (just "hot-(re)plugging the SATA data cable" wasn't enough). However I still don't understand why an `fstrim` on a partition spanning the whole disk wouldn't work. – Pavel Tankov Feb 08 '18 at 13:17
  • I found these 2 places discussing `hdparm --security-erase-enhanced` vs `blkdiscard` very interesting and informative: https://superuser.com/questions/1060831/triming-as-alternative-to-securely-erasing-a-ssd/1061437 and: https://www.spinics.net/lists/util-linux-ng/msg10356.html It boils down to: "In general, I would expect the performance gain from TRIMing the entire drive to be either the same-as, or possibly less-than the gain from SECURITY ERASE. For a sane firmware implementation I'd expect them to have the same effect on performance. **Firmware implementations are not always sane.**" – Pavel Tankov Feb 20 '18 at 15:07