TRIM, Deallocate and Garbage Collection
Deleting a file, telling the device that a range is no longer needed, and physically erasing flash are three different events. Each depends on the filesystem, the storage path and the device, so a zero-filled read or a “TRIM enabled” setting does not by itself say what happened to a particular range.
- Deletion updates metadata, which is itself a write, but does not necessarily overwrite the file’s content bytes.
- TRIM, Deallocate and UNMAP are related commands in different standards; what a later read returns depends on device and features.
- Each layer between filesystem and flash may pass, translate, defer, reject or not support a discard.
- Zeros can be a deallocated read, a sparse hole, an unread placeholder or real data; one sample does not diagnose TRIM.
- Garbage collection also runs without TRIM, and no external countdown predicts when a range is physically erased.
What deletion writes and what it leaves
Deleting a file changes filesystem metadata: directory entries, allocation bitmaps or trees, often a journal. Those updates are writes to the device. What deletion usually does not do is overwrite the file’s content: it removes the references and marks the space free, and the content stays until the space is reused or discarded. Whether the filesystem then sends a discard immediately, in batches or not at all depends on the filesystem, the operating-system and mount settings and, for some data, on applications that truncate or rewrite files themselves. Secure deletion is a different operation.
TRIM, Deallocate and UNMAP are related, not identical
SATA devices receive discards as ATA Data Set Management with TRIM; NVMe devices as Dataset Management with the Deallocate attribute, and the NVM Command Set also lists Write Zeroes among the commands that can deallocate a block; SCSI devices, including many USB bridges and virtual disks, as UNMAP. They express the same intent — the previous contents of these logical ranges no longer need to be preserved — but each standard defines its own capability reporting and its own rules for later reads.
Where the data physically lives inside the device remains internal to the controller. What the host can expect to read back, however, is not entirely up to firmware: it is bounded by the standard, the version the device implements and the features it advertises for that namespace or logical unit. Establish those for the actual device before interpreting a result. This page does not restate the ATA and SCSI rules; for them, the device’s reported capabilities and the standard it claims are the reference.
What a read returns after deallocation
A read of a deallocated range can return zeros, another defined pattern, or an error, depending on the command set and the device’s features. NVMe illustrates the range of answers. Revision 1.3 added a way for a namespace to report what deallocated blocks return; that field can report all bytes cleared to zero, all bytes set to FFh, or that the behaviour is not reported. The NVM Command Set also defines a “Deallocated or Unwritten Logical Block” error status that a read can fail with instead of returning data.
None of this promises either old data or zeros. A device that reports nothing gives the host no basis for assuming zeros, and devices that predate these fields, or follow another command set, should not be read through modern NVMe semantics.
Each layer decides whether a discard goes further
A discard issued by a guest filesystem may pass through a virtual disk, a host filesystem or thin pool, a RAID or encryption layer and a USB or controller bridge before it reaches flash. Each layer can pass it through, translate it into its own terms, defer it, reject it, or not support it at all. A virtual disk may turn it into a hole in its own allocation map: VHDX, for example, has a block state for ranges that received UNMAP, which reads back as zeros or as the previous contents. Some refusals are reported; not every gap is silent.
A capability flag or an operating-system setting shows configuration, not delivery of a specific range. “The SSD supports TRIM” does not establish that this deletion was trimmed. See Sparse, Thin-Provisioned and Virtual Storage Recovery for the layers above the device.
Zeros are not a diagnosis
A run of zeros in a recovered file or image can be:
- the device’s logical response for a deallocated range;
- a sparse hole in an image file or thin volume;
- a guest range that a virtual-disk format defines as zero;
- a placeholder written by imaging or conversion for an area that was never read;
- data that really was zero.
One zero-filled sample does not diagnose TRIM. On a failing drive, reading the whole affected range again just to check is not free either. Use what already exists: the imaging map, logs of what was read, earlier read results and independent backups. See What a Disk Image Preserves — and What It Does Not.
Garbage collection and physical erase
Flash is written out of place: the controller writes new data to a fresh page and updates its mapping, leaving the old page invalid. Ordinary overwrites therefore create invalid pages just as discards do, and old physical copies can persist after a logical overwrite. Garbage collection reclaims space by copying still-valid pages out of a block, erasing the block and returning it to the free pool. Erase works on whole blocks of many pages; a page is not an erase unit of its own.
Garbage collection does not start only after TRIM and does not wait for idle time: it can run under write load when free blocks run short, and its timing also depends on over-provisioning, thermal and power state and the model. TRIM gives it more pages it may treat as invalid. It does not schedule their erasure. See SSD Recovery Fundamentals: TRIM, FTL & GC.
Power, time and handling decisions
Additional powered time can let internal maintenance progress, but there is no externally visible countdown for a particular range, and no universal rule for retries. Neither “unplug immediately for chip-off” nor “keep it powered for tests” is a rule. The decision depends on the case: whether an authorized unlocked or plaintext state exists that power loss would end, the drive’s physical health, and whether logical acquisition is still possible. A host-side write blocker does not stop the controller’s own maintenance; see SSD Firmware, Translator and Controller-Level Recovery.
Raw remnants, logical paths and USB flash
Physical pages can hold deallocated data until they are erased, but turning them into files needs the mapping that says which page belongs where, the generation of each copy, error correction, descrambling and, on encrypting devices, the key context. The existence of bytes in flash does not guarantee that a file can be recovered. At the same time, software that reads through the normal logical interface sees only the controller’s current answer; it cannot “scan deeper” past the controller for a range that already reads as zeros.
A USB flash drive runs its own translation, wear levelling and garbage collection whether or not the host ever sends a discard. Whether a given USB device accepts discards is a property of its controller or bridge, not of its shape: some USB enclosures hold complete SSDs. See Flash and SSD Controller Recovery Tools.
What a result can and cannot show
Record what was observed: which ranges, through which access path, on which copy, with what result. If the needed bytes are no longer available through the chosen logical path, look for independent copies with their own scope — filesystem or storage snapshots, backups, replicas, cloud versions. One logical response is not grounds for declaring that data has been physically destroyed, and it is not grounds for assuming it survives in flash either. See What Overwrite Actually Destroys.
Before concluding anything about remnants, record which ranges were read, through which path and what came back, and look for independent copies — both before assuming the data is gone and before assuming it survives in flash.
Technical references: NVM Command Set Specification 1.1 — operations that deallocate (§2.1), deallocated-block read error (§3.1) · NVM Express: changes in revision 1.3 — reporting of deallocated read values · libnvme: nvme_id_ns_dlfeat — the reported read-behaviour values · Wei et al., FAST ’11, §2.2 — out-of-place writes leave old physical copies. The NVMe statements follow the NVM Command Set 1.1 and fields added in revision 1.3; older NVMe devices and ATA or SCSI devices follow their own standards, and when a range is physically erased is controller-specific.
Related: SSD Recovery Fundamentals · Flash Translation Layers and NAND Reconstruction · What Overwrite Actually Destroys · Why Deleted Files Usually Can’t Be Recovered on an SSD · Chip-Off, ISP and Monolithic Flash Recovery