UFS Wiping out data from FreeBSD disk partitions

With the wear levelling stuff: is it possible for a data fragment that was previously in that part of the device to be elsewhere now?
It's not so much the wear levelling, it's the internal virtualization and overprovisioning.

Internally, SSDs are built out of flash chips. Those flash chips have a block-based architecture, and only a whole block can be erased. Within a block, sectors can be written, but only once; the next time they need to be written, the block needs to be erased first. That means to perform a sector write, a new copy of the sector has to be moved to a new block. As the sectors move around, eventually a while block becomes unused, and then it is bulk erased. This means that SSDs contain internal virtualization, where the location of a sector is mapped to pretty much arbitrary blocks.

Flash has a limited lifetime. So what vendors do: If you buy a X GB SSD, they actually install X+Y GB of flash in it. Then, as parts of the flash chips become unreliable, they can be taken out of service, but the overall capacity of the device stays the same.

What this implies is that a SSD contains complex firmware inside. Usually, it's pretty similar to a log-structures file system, with bulk erase control and wear leveling thrown in. Those firmwares are called FTL - flash translation layer.

At any given point, most blocks are full of older data, much of it not accessible through the interface, because the firmware looks at the metadata. If someone takes the SSD apart and reads the chips directly, that older data will show up. So if you are interested in data security, make sure nobody steals your SSDs, and if you want to throw them away, run them through a shredder first. Same as with hard disks. Actually, today you can just use an encrypting SSD or encrypt your data, then once you throw the encryption keys away, you can be pretty sure the data is unreadable.
 
With the wear levelling stuff: is it possible for a data fragment that was previously in that part of the device to be elsewhere now?
Yes, that might be the case but it depends.


Wear Levelling - extending the life of SSDs

SSD storage technology is very different from HDs with spinning platters: they have different properties as to how they wear and how the underlying physical writing processes work. As the name suggests the technique of wear levelling is used to evenly wear out every individual memory cell[1]. A block consists of several pages and each page can be written to individually. (This block may be different from a disk block in OS terms.) However, a block must first be erased when it already contains data: a block is the minimal entity that can be erased. Thus, before a block that contains data can be written to, it must be erased as a whole. Wear levelling is all about limiting the P/E (=program & erase) cycle count per block and thereby extending the life expectancy of an SSD; there are different ways to do that.

Before wear levelling was used over provisioning was one way to combat blocks that are "near death". At a certain point in time, a block that is near its maximum P/E cycle count will be not be considered for a further erase and program cycle. When that block is being deleted by the OS, the SSD controller can swap its target address with the address of a block from the over provisioned storage area. To the OS this swap is invisible and other blocks in the over provisioned area that are still unused are not accessable to the OS. When the deleted and swapped block is only exchanged and not erased then the data is still on the SSD but not accessible from the OS: a normal user cannot retrieve it. Only software that interfaces with the SSD controller in a special way enables the retrieval of that hidden data block. When there are no more unwritten blocks available in the over prisioned area, the total amount of available storage as seen by the OS starts to shrink and your SMART software probably starts to output more and more bad news ... This mechanism of over provisioning managed by the disk controller is also used by HDs with spinning platters.

With dynamic wear levelling not all blocks are worn out evenly, only a certain group of blocks. Files that hardly change over time have minimal wear and probably retain that level of wear during the lifetime of the SSD; they are, for all intents and purposes, read-only. The typical example is your photo and video collection. These files are "out of the reach" of the pool of blocks that are the target of dynamic wear levelling. That means that there is a notable difference in life expectancy between, say, an 80% full SSD (with read-only files) compared to a 90% full disk (with read only files). In the video SSD Life Expectancy, Christopher Barnatt explains general SSD properties; he discusses (dynamic) wear levelling briefly. However, he does not mention static wear levelling. He may have had good reason to do that—I'll come to that at the end.

With static wear levelling all blocks, even the blocks containing data that are effectively "read-only" are considered a possible target to be moved around. A data block, not-erased in a long time, can be moved to a block that is near the upper limit of its wear threshold. Static wear levelling takes every block into consideration and sees to it that all blocks stay within a "range of wear"; that is above a minimal threshold limit and below an upper threshold limit. Those limits are not fixed but change as the range of wear as a whole moves when more blocks get written[3] over time. Dynamic and static wear levelling[2] is nicely explained in the video Wear Leveling | How Does Static & Dynamic Wear Leveling Impact NAND Flash Life Expectancy (#8)

Static wear levelling works on a flash chip level. As an SSD usually contains more than one flash chip, that means that one flash chip may wear out considerably sooner than another flash chip, even though within each individual flash chip all blocks wear evenly.

Extending the process to all flash chips together means having one big pool that makes all the blocks of an SSD wear out evenly, even if they are on different flash chips. This is called global wear levelling.

So, with dynamic wear levelling "read-only" data blocks stay in the same place on the flash chip where they were initially written. However, with static wear levelling "read-only" datablocks will be moved around inside its containing flash chip. With global levelling data blocks may be moved around between all the flash chips of the SSD.

Wear levelling is transparent to the OS: it is run and executed by the SSD controller behind the scenes. Static wear levelling is a lot more resource intensive. As the Wikipedia table comparing dynamic and static wear-leveling mentions, static wear levelling is in the domain of industrial grade SSDs.

___
[1] "memory cell" is somewhat flexible here: SLC contains a one bit memory cell, MLC 2 bits, TLC 3 bits and lastly QLC 4 bits.
[2] More extended articles:
How Wear Leveling Extends SSD Life Expectancy
Wear Leveling – Static, Dynamic and Global
How Controllers Maximize SSD Life
[3] Graphically shown by the range between the two moving dashed horizontal green lines in Wear Leveling | How Does Static & Dynamic Wear Leveling Impact NAND Flash Life Expectancy (#8) at ca. 3:20 min.
 
Back
Top