DevilsPGD said:
Wear leveling happens at the firmware level, below what Windows is aware
of or can interact with.
Wear leveling is totally automated, and below the level Windows
can see or work at.
There is one level of indirection inside the SSD. You say
read block 0, the SSD consults an internal table, and
reads physical block 12345. If you write block 0 on the
outside of the drive, the drive internal controller
goes to the list of free blocks, and picks the next one
there. Maybe it is 13579. The new data is written there.
Windows (and the user) may think they've just dealt
twice with block zero, but inside, physical block
12345 and 13579 were used. The user has no idea, where
exactly the data is stored. (You wouldn't immediately
know where to look with your electron microscope.)
By the controller keeping count of how many times that
has happened to each block, it's possible to point more
of the operations towards blocks that haven't been used yet.
Commands such as TRIM, provide "hints" to the controller.
Some controllers function without TRIM, and they figure out
which blocks aren't being used, which blocks are fractionally
used, or whatever. If TRIM information is available, that
just adds to the knowledge base the internal controller
has to work with. Data may be rearranged, for best
efficiency when the drive is next used.
As an example, if you use an Anandtech-style 4KB random
block write test, that makes a mess out of your SSD. Later,
an attempt to do what you think is a sequential write, seems
to be a lot slower. That's because the drive is now fragmented,
and some internal rearrangement is needed. If instead,
you leave the SSD powered up overnight, the internal
controller can attempt to clean up the mess from the 4KB random
write test. By the next morning, it's shifted enough fragments
around, such that your next attempt to do a sequential write,
is back to full speed.
These are examples of, as "DevilsPGD" describes them,
firmware-based operations, below the level that Windows
sees. And just like a hard drive has a controller, and
fully automated operations it does (bad block substitution),
the SSD has even more of those kinds of operations.
*******
The first wear-leveling implementation, was done as a
software driver. I thought at the time, that the patent
on wear leveling (by M-Systems), would create an uneven playing
field for flash devices, but it hasn't seemed to hurt at all.
http://en.wikipedia.org/wiki/Wear_leveling
"M-Systems product DiskOnChip used a software driver
named TrueFFS which performed wear-leveling of
NAND flash chips and made them appear to OS like
a conventional disk drive."
http://en.wikipedia.org/wiki/M-Systems
"After 17 years of business, they were acquired by
their prior competitor, SanDisk, in 2006."
Since that time, and especially with SSD designs,
that function has "moved underground", and it's not
done as a Windows driver. It's fully automated, and
done in hardware.
I'm not really sure, whether USB flash sticks
have that feature or not. I suspect they do,
but I don't know whether there is a controller
in there to do it or not. I don't think it's done
with an OS driver.
Paul