What Happens When We Delete a File
On a traditional hard disk drive, if a file is deleted, it’s only the index that has been removed. To the file system, the file is deleted and the space it takes is marked as "not in use". But in fact, the file still exists as raw data on the hard drive. When the operating system requires more space, it will simply overwrite this "not in use" space. A traditional hard disk drive is able to overwrite data in one single operation, but a solid state drive first has to erase all data in this "not in use" space before it is able to record the new data.
The NAND flash memories are commonly used as the memory storage medium in SSDs. NAND flash is organized into Pages and Blocks. Each Block contains a specified number of Pages, which in turn contain a specified amount of data (2 to 8KB). Unlike traditional rotating hard disk drives, data in NAND flash can’t be directly overwritten. While data can be read and written at the Page level, erase can only happen at the Block level. In other words, you can read or write any number of Pages from a Block or to a Block, but if you want to erase any part of that Block, you have to erase the whole Block.
What this means is that data must be constantly moved around in order to free up Blocks for reuse, which slows down the entire read/write process. What's more, due to the finite read/write cycles of NAND memories, the constant shuffle of data will fasten the deterioration and reduce the lifespan of the SSDs.
The Introduce of TRIM
This is where TRIM steps in. The TRIM command is designed to enable the operating system to notify the SSD which pages no longer contain valid data due to erases either by the user or operating system itself. During a delete operation, the OS will mark the sectors as free for new data and send a TRIM command to the SSD to mark them as not containing valid data. After that the SSD knows not to preserve the contents of the block when writing a page, resulting in following benefits:
1. Lowered write amplification. Less data is re-written and more free space is available during Garbage Collection.
2. Higher throughput. During the time the SSD is doing Garbage Collection, the drive has to stop some of the data transfer from the host while it moves data around. This is why it’s beneficial for the SSD to know which data is invalid so it doesn’t have to be moved during GC.
How to Enable TRIM in Windows
TRIM has been supported since Windows 7 and will be automatically enabled if the OS detects SSDs. But if you want to be sure, here's how to check and enable TRIM in Windows7, 8, and 10.
1. Open a Command Prompt window (run as administrator)
2. Type the following at command prompt and press enter:
3. There are two possible outcomes:
DisableDeleteNotify = 0 : TRIM is enabled and working in Windows
DisableDeleteNotify = 1 : TRIM is not enabled
4. To enable SSD TRIM support in Windows, type the following at command prompt and press enter:
TRIM has been supported since Windows 7 and will be automatically enabled if the OS detects SSDs. But if you want to be sure, here's how to check and enable TRIM in Windows7, 8, and 10.
1. Open a Command Prompt window (run as administrator)
2. Type the following at command prompt and press enter:
fsutil behavior query DisableDeleteNotify
3. There are two possible outcomes:
DisableDeleteNotify = 0 : TRIM is enabled and working in Windows
DisableDeleteNotify = 1 : TRIM is not enabled
4. To enable SSD TRIM support in Windows, type the following at command prompt and press enter:
fsutil behavior set DisableDeleteNotify 0
How TRIM Affects Data Recovery
On an SSD with TRIM enabled, if you delete a file, the system will erase it and you’re most likely not going to get your data back. However, there are several exceptions.
- TRIM is not effective in RAID environments.
- Trim is not effective in external SSD drives with USB connection cables.
- Older Operating system and older types of SSDs doesn't support TRIM.
- Not all file systems support TRIM. (In Windows, only NTFS)
Besides, different SSD drives handle TRIM differently. If you ever lose data on TRIM enabled SSDs, don't panic yet. Choose a professional data recovery software to see if any useful data can be salvaged.
No comments:
Post a Comment