My partition /dev/sda3 on an SSD drive doesn't contain any filesystem, but it contains garbage. How do I do a TRIM/DISCARD operation on the whole partition?

link|improve this question

65% accept rate
I'm a little confused.. Do you want to destroy the existing garbage data? Can you not just format the partition? You could use dd to write that partition with zeros or random data (from /dev/zero or /dev/random). I'm just confused as I'm not sure if "TRIM/DISCARD" means something really particular that isn't covered by my suggestions..? – Doc Jul 8 '11 at 19:31
2  
I think the point is that he doesn't want to write any data, he wants the SSD to ERASE the flash block but leave it empty so it's available to be written to, known as freshing an SSD drive. – Chris Thompson Jul 8 '11 at 20:44
feedback

2 Answers

You could have a look at the script wiper.sh included with the hdparm package. It uses the hdparm command --trim-sector-ranges to TRIM all empty sectors on a partition, at least if it contains an ext3/4 filesystem. Not sure if it works with unformatted partitions, but you could always temporarily format it with ext4.

link|improve this answer
Formatting it with ext4 and then running wiper.sh would trim almost all of the partition except for the ext4 metadata. But I'd like to trim the whole partition. – pts Jul 13 '11 at 22:24
2  
@pts: I suggest you look at the code of wiper.sh and try to figure out how it deduces the trim ranges. Then you could manually send a trim range to hdparm to TRIM the whole partition. – eldering Jul 14 '11 at 8:40
feedback

Here's an interesting article that talks about using HDDErase to invoke the SSD's built-in secure erase feature, which should get you want you want:

http://www.windowsitpro.com/article/file-systems/q-how-can-i-reset-a-solid-state-disk-ssd-to-a-fully-erased-clean-state-

link|improve this answer
Thank you for your answer, but it doesn't work, since 1) it erases the whole drive 2) it requires Microsoft Windows, and I was looking for a Linux solution. – pts Jul 13 '11 at 22:23
ATA Secure Erase works also for Linux, ata.wiki.kernel.org/articles/a/t/a/ATA_Secure_Erase_936d.html – Lekensteyn Dec 13 '11 at 11:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.