Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

From a (very long, but definitely worth to read) article on SSDs:

When you delete a file in your OS, there is no reaction from either a hard drive or SSD. It isn’t until you overwrite the sector (on a hard drive) or page (on a SSD) that you actually lose the data. File recovery programs use this property to their advantage and that’s how they help you recover deleted files.

The key distinction between HDDs and SSDs however is what happens when you overwrite a file. While a HDD can simply write the new data to the same sector, a SSD will allocate a new (or previously used) page for the overwritten data. The page that contains the now invalid data will simply be marked as invalid and at some point it’ll get erased.

So, what would be the best way to securely erase files stored on a SSD? Overwriting with random data as we are used to from hard disks (e.g. using the "shred" utility) won't work unless you overwrite the WHOLE drive...

share|improve this question

6 Answers 6

How about encrypting the volume itself? The deleted data will still be there but should be inaccessible to anyone without the appropriate key.

share|improve this answer
    
Funny I didn't think about that - as I always use LUKS encryption on my hard disks anyway ;) –  c089 Aug 13 '09 at 11:19
    
Good idea teabot. Thanks. –  JamesC Dec 31 '09 at 10:02
    
As stated here this will have serious performance impacts. With SandForce-based drives, using ATA secure erase will wipe the AES encryption key, providing a solution to the secure delete problem when not using software encryption. –  c089 Feb 27 '11 at 12:10

If the SSD drive supports the ATA security mode feature set, then it has secure erase functionality built in, which you should be able to access using something like Secure Erase.

share|improve this answer
2  
+1 for ATA security mode feature set. There's a good video on this on SecurityTube.net –  RJFalconer Aug 13 '09 at 14:30
1  
But that feature is only for complete drives as well, isnt it? –  c089 Aug 14 '09 at 14:23
    
@Chris089: That's correct: secure erase will erase the whole drive. Overwriting the entire drive with random data is not guaranteed to erase the whole drive, due to underprovisioning. (But it could make some of the unerased data inaccessible to ordinary users, at least.) See anandtech.com/storage/showdoc.aspx?i=3531&p=9 for more info. –  bk1e Aug 14 '09 at 16:46
    
Beware that (older) drives have been found to not implement this feature as it should. It should also work for HDD's, but on SSD's it has the advantage that it may actually finish in seconds instead of hours. –  Maarten Bodewes - owlstead Oct 5 at 15:03
    
A frustrating issue with Secure Erase is that many drives require you to physically power-cycle them (unplug the power connector and plug it back in) in order to get them out of their "security frozen" state. Only then does Secure Erase work. Not always easy or desirable having to open up your PC, especially when it's a laptop or worse embedded system. –  misha256 2 days ago

Even if you overwrite the whole drive, you cannot be absolutely certain since both HDs and SSDs contain spare sectors that are substituted when failures occur, or in the case of SSDs to aid wear levelling.

If you want to be absolutely certain the data is irrecoverable gone, you have to physically destroy the drive beyond recovery. Overwriting gives you reasonable certainty on HDs - on SSDs, there isn't really a way to achieve even that. If you fill the whole drive, it's still possible that the block the data was in has been switched to a spare block for wear levelling and will reappear later.

share|improve this answer
    
Cannot downvote yet, but the secure erase answer invalidates this argument. Of course, if you don't want to rely on the secure erase of the manufacturer, then physically destroying the flash is an option. But make sure you incinerate it or break all the chips, flash is very resilient. –  Maarten Bodewes - owlstead Oct 5 at 12:50
    
Note that this is an old answer; by now the SECURE ERASE should be supported by most if not all drives, including most hard disk drives. –  Maarten Bodewes - owlstead Oct 5 at 15:02
    
Secure Erase wipe all SSD. But not separate file set or partition. –  mmv-ru 2 days ago
up vote 5 down vote accepted

As stated by @teabot using full disk encryption software will circumvent the issue of secure deletion because you don't have to any more. However, as stated in a related question, this will have huge performance impacts because this prevents a lot of the controller's features like compression and TRIM and has been reported to decrease the performance up to a level where a normal hard disk is faster then the expensive SSD. For SandForce-based devices, there is a better solution: Those devices do AES encryption by default and the key will be wiped when you use the ATA secure delete feature, making all data unaccessible unless the attacker can break AES (128bit for current, 256bit for the new drives released in march 2011).

share|improve this answer
    
However, there doesn't seem to be a solutio for securely deleting just a few files. You have to erase the whole disk. –  c089 Mar 1 '11 at 7:26

Because of the nature of NAND flash memory, SSDs cannot directly overwrite data. Repeatedly overwriting a file before deleting it will not securely erase it on an SSD—the data would just be written elsewhere on the NAND.

To understand why this is the case, it is necessary to explain how SSDs work on the inside.

  • NAND flash is divided into blocks, each consisting of a set of pages typically 4 KB in size (plus error-correcting codes). Most modern SSDs uses NAND with blocks of 128 pages for a block size of 512 KB, although some drives, especially older ones, may use 256 KB or smaller blocks. The following diagram assumes 256 KB blocks, but the concept is the same regardless of the block size.

Diagram of pages in a NAND block
Source – Courtesy Music Sorter at Wikipedia, CC BY-SA 3.0

  • Each page may be written to individually, but pages cannot be rewritten until erased, and erasing can only be done in whole blocks. This means that whenever data is rewritten, the SSD must mark the data in the affected pages invalid and rewrite it elsewhere, possibly in a different block. At a more appropriate time, ideally when the drive is idle and all pages in a block are marked invalid, the SSD can erase blocks that are no longer in use. This cleanup process is called garbage collection.

  • In order for the SSD to know which blocks can be erased, the operating system must tell it which blocks no longer contain valid data. This is done using the ATA TRIM command. The SSD is then free to garbage-collect those unused blocks.

SSDs try to spread writes evenly over the NAND to avoid premature failure, a process which relies on the free space available to the drive.

  • Each NAND block can only sustain a finite number of write/erase cycles. Many of today's consumer-grade SSDs use 19-21nm NAND where each block is good for about 3,000 cycles before becoming unusable, although enterprise SSDs and several high-end consumer SSDs that use more durable types of NAND are commercially available.

  • In all cases, however, SSDs must spread writes out over the entire drive to avoid placing undue wear on any single block in order to avoid premature failure of the drive, through a process called wear leveling. Efficient wear leveling can only be achieved if there is a certain amount of space (over-provisioning) that is reserved to allow for efficient garbage collection as required even if the drive is nearly full.

  • Under extreme conditions where the SSD is being asked to write data faster than it can erase old blocks (common in write-heavy datacenter workloads), it may be forced to rewrite the data in one block into another block, then erase the old block immediately to make way for new data, before it has had a chance to perform garbage collection.

  • Forced rewriting of a block is less than ideal because it degrades performance and contributes to write amplification, where more data is written to the underlying NAND than the actual amount the drive is instructed to write. Added over-provisioning helps mitigate write amplification by providing more spare space to rewrite data and erase old blocks. This is why high-end enterprise SSDs such as the Samsung SSD 845DC PRO come in sizes like 200 GB and 400 GB even though the drive actually contains closer to 256 or 512 GB of NAND inside, respectively. See also: Why do SSDs have weird sizes?

  • Samsung's SSD white paper series provides a thorough explanation of the inner workings of SSDs. Writing and erasing NAND pages and blocks and garbage collection is explained in white paper 04.

The only way to truly erase data on an SSD is to use the ATA Secure Erase commands.

  • Secure Erase instructs the drive to wipe all stored data, including data which may remain in the over-provisioned NAND regions. All blocks are erased when this is done, resulting in a pristine drive.

  • In drives with self-encrypting capability, Secure Erase can simply be implemented by wiping the encryption key. Since the data on the NAND of an encrypted drive is unreadable without the key, there is no need to erase all blocks as would be necessary on an unencrypted drive.

share|improve this answer
    
Beware that not all drives correctly implement the secure erase commands. If you still want to use the drive, that might be the best you can do if you didn't have the foresight to encrypt from the start. If you want to dispose of the drive, you should physically destroy it - especially the flash chips. –  Bob 2 days ago
    
If physical destruction is required, I'd open up the drive and destroy the underlying PCB. –  DragonLord 2 days ago
    
@Bob Do you have a link to a source discussing incorrect implementation? The secure_erase command is part of the ATA standard. It may not be present on some cheaper drives, but if it is there it should work properly. The reason it works better than other options is that it restores the drive to its original factory configuration. Even on HDDs it is faster and more effective than tools like DBAN. –  Paul yesterday
    
@Paul security.stackexchange.com/questions/41676/…, usenix.org/legacy/events/fast11/tech/full_papers/Wei.pdf, security.stackexchange.com/questions/62253/… There is absolutely zero guarantee an arbitrary drive's firmware correctly implements any given command (bugs can happen anywhere) - and testing has proven that at least some drives definitely do not. At the end of the day, the biggest issue is you cannot really verify correct erasure. –  Bob yesterday
    
Since we cannot make a blanket statement/guarantee of success, we must assume at least some drives do not implement it correctly. If we assume some drives do not implement it correctly, then the safe thing to do is to assume no drive implements it correctly until proven otherwise. And it's not easy to prove - erasing might look correct to you, while retaining information on the flash chips for all you know - which means you should always physically destroy for anything really sensitive. –  Bob yesterday

As you thought, wiping all the free space to ensure that any blocks that used to contain the data are wiped is the only way to be sure. Well, other than taking of an nuking the site from orbit...

This will be quite time consuming, and will reduce the life of the flash chips, if you use a multi-pass shred.

The other way to protected the deleted data is to store it encrypted in the first places using an encrypted filesystem using something like truecrypt.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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