I'm trying to understand this. Say I have a 256GB SSD, 180GB of which are already occupied by permanent files (OS, installed programs etc.). The remaining 70GB or so gets new files created and deleted. Doesn't this mean the the NAND chips of that portion will get weared out earlier than the area whose files are not modified? Or does SSD move the non-changing files too over the course of time?
1 Answers
The SSD moves non-changing files around over the course of time.
First of all, you have the virtual sectors that are exposed to the operating system (not to be confused with file system clusters), and then you have the physical cells in the flash chips. As the flash controller allocates/deallocates cells, it remaps the virtual sectors accordingly so it is transparent to the operating system (the same virtual sectors may appear at different locations in the flash cells at different times).
Second of all, SSDs actually have spare cells that are not usable as free space. They're specifically set aside for the purpose of wear leveling, mitigating write amplification, and remapping dead cells. That way, even if your SSD has zero bytes of free space on it, the flash controller still has room to perform wear leveling.
Let's say you have a 500 GB SSD that is 100% full. Now let's say that 499 GB of that data is a file that never changes, but you have a 1GB file that changes all the time. If you delete that 1GB file and then copy over another 1GB file, the flash controller will do one of two things at that moment:
- All or some of the new data will be allocated to spare cells, leaving the old cells in a still-trimmed state.
- 1 GB worth of cells within the 499 GB of data that never changes will be copied to other available cells. The old cells will then be erased and rewritten with the new data.
In both cases, the virtual sectors presented to the operating system never change, so the OS is unaware of what's actually happening. The flash controller keeps a mapping table of memory cells to virtual sectors.
The wear leveling algorithm's goal in life is to try and exercise all the cells evenly, even if that involves moving data around to achieve it. This process does slow the drive down, and it does (ironically) cause additional wear to the flash cells. It's called write amplification and it's a significant problem with SSDs. The actual wear leveling algorithms employed by SSDs and the ways they mitigate write amplification are proprietary trade secrets among SSD manufacturers, so this is just a general descripton of the process.
- 14,102