Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From the Wikipedia page of TRIM I get the impression that TRIM was introduced to lower the writes to a SSD, but letter the file system taking case of which blocks are unused.

If that is correct, does that mean, that SSD's that don't use TRIM writes zeros to the blocks, when a file is deleted, to let the SSD know the blocks are free?

Reading this

File systems within a guest tend to not reuse blocks which means that even if a file system remains small relative to the virtual image size, the actual image size tends to grow until it reaches the maximum size.

leads me to think, SSD's don't overwrite with zeros? Or are file systems in guests, something completely different?

share|improve this question

migrated from Jul 10 '11 at 12:33

This question came from our site for system and network administrators.

up vote 10 down vote accepted

Flash memory devices (what's used for today's SSDs) can't write arbitrary data at any moment; before writing on a cell (typically 4KB) has to be erased first. Unfortunately, the erase operation is very slow; that's why flash devices were so much slower than magnetic drives, despite having no moving parts.

Modern SSDs hide the erasing time by maintaining a set of pre-erased cells, that means that a write command won't immediately overwrite existing data, instead the drive's controller picks an erased cell, remaps it, and writes with the new data. That (and several write-thought cache strategies) gives the drive a huge speedup, greatly surpassing magnetic drives.

To ensure that there's always a set of preerased cells, any time a cell isn't needed, the drive schedules it for background erasure and adds to the list of fee cells.

Unfortunately, existing filesystems didn't bother to tell the drive when a sector was free. The drive was supposed to be just a dumb repository of bits, after all. Deleting a file or any other operation that marks a sector as free from the filesystem's point of view was only a mark on some metadata structure. The sector itself wasn't touched. Even if the filesystem cleared it by writing zeros over it, the drive couldn't know if that meant the sector was free, or if the user wanted some zeros on a file. After a time, the drive wouldn't have any free cell to erase before writing; and performance degraded tragically.

The TRIM instruction was quickly drafted and adopted by most filesystems currently maintained. It's a simple signal that the filesystem uses to tell the drive that the content of a sector isn't important anymore. As soon as all sectors mapped on a cell are free, the SSD controller unmaps the cell and schedules it for erasure. If the host read those sectors, the SSD wouldn't bother fetching from Flash, it immediately responds with zeros; but the most important effect is to keep the list of preerased cells always replenished.

Still, most SSDs expose a smaller capacity than the physical size of the Flash memory, sometimes as low as 75%. That allows it to keep some unused cells even on a 100% full system, so that (over)writing used sectors is still fast.

share|improve this answer
Interesting. I conceptually knew about how TRIM worked but wondered about how much storage an SSD would expose. Now I want to see if that data is published anywhere for given SSDs... – Michael B Jul 10 '11 at 8:22
The amount of the reserved cells is usually published. It's commonly between 5 and 10% for cheaper consumer drives, 20%+ for higher end consumer drives. Enterprise Flash Drives (EFDs) tend to have a reserve anywhere from 100% to 400%; hence why they're so darn expensive, they keep this massive reserve because writing to a flash memory location destroys the locations a little bit every time. Write heavy applications, typically found in server environments, would kill most consumer SSDs quickly. – Chris S Jul 10 '11 at 14:35

TRIM was introduced so an Operating System (the File System within the OS) could communicate to an ATA storage medium that a sector is no longer being used by the file system. This has nothing to do with writing to the disk.

TRIM does not guarantee the sector is zeroed on the media. It does guarantee when the file system requests a read from that sector that zeroes are returned (note that because the SSD knows the sector should be zeroes that it will return them regardless of what is actually stored in the media; it may be possible to recover data from a disk that has simple been trimmed, though typically SSDs actually do erase the memory).

File systems do tend to distribute their writes (for a variety of reasons, every thing from attempting write leveling, to garbage collection, to randomizing storage locations, and more). Because of this, if the media is unaware of which sectors the file system is not using, simply writing zeroes does not necessarily mean the sector is unused, then it must assume eventually that the whole disk is in use.

For SSDs this assumption means that a sector must be erased at write time, decreasing write speed; instead of erasing the memory location at the time the file is deleted. Similary for virtual disk files in virtualization systems, the dynamic disk file will eventually encompass the full capacity of the virtual disk. If the virtualization system implements TRIM then it will know when a sector is no longer being used, and hence that the dynamic disk does not need to keep track of that location.

share|improve this answer
Does that mean, that TRIM was introduced to let the SSD know which sectors are used, so it can put the new data on sectors that have been used less? – Sandra Jul 10 '11 at 8:27
SSDs simply use TRIM to know when a sector is no longer needed. It does not guarantee write leveling or any other features the storage medium may implement. That said, most SSDs do use it for write leveling, garbage collection (in flash media, erasing unused sectors), and keeping free sector lists for improved write performance). – Chris S Jul 10 '11 at 14:38

Your Answer


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.