5

How do you TRIM completely unused, unallocated, unformatted, unpartitioned space (but other volumes still exist) on an SSD in Windows 11, that used to contain data, for over provisioning? (For note: when I say "empty space" I mean space that is now unallocated, unformatted, etc., not necessarily unused space in an existing volume/partition.)

I've looked around and found a lot of answers for people asking similar questions about "empty space" that never contained anything (such as on a new drive), so a TRIM is unnecessary, and that's understandable. However, I used to have my entire SSD partitioned and formatted and had regularly nearly filled it up (certainly more than the unused space I'm trying to over provision now) and only recently realized there are many benefits to over provisioning that outweigh the loss of storage space. I didn't do a TRIM before shrinking the partition however, so the SSD may think there is still data in that now "empty space".

I am under the assumption that TRIMing a volume (C, D, etc.) only applies to the "space" (sectors/blocks, whatever) that volume occupies (or could potentially occupy, including its unused space), but does not TRIM outside that volume (presumably so it's not TRIMing space that only Windows doesn't know about).

So, if I want to be sure that the SSD firmware knows that space is available for over provisioning, how can I be sure it knows? Is there a command or tool to tell the SSD firmware specifically that it's for over provisioning, or how can I TRIM that "empty space" (that used to be used) outside any volumes?

If there is not a command or tool to TRIM the "empty space", would just creating a new partition/volume in the space I want for over provisioning, TRIMing that, and deleting it effectively do what I want?

3
  • For example, my C drive is a 2TB NVMe SSD. The entirety of the drive was occupied by volumes (the standard UEFI, Boot, Recovery, and "C" partitions). I had filled up my C partition with data. I got another new SSD to move a bunch of those excessive files to, then shrunk the C volume. That now-unallocated space is obviously unallocated to the OS, but the SSD likely has no clue what's there and may think those blocks/sectors/cells are still being used. Commented Feb 13 at 17:35
  • 2
    I think it's enough to create a RAW partition in that "unallocated" area using for example disk management for disk management to TRIM that area. Other than that I don't think there's easy ways in Windows to TRIM what disk management refers to as "unallocated space". Commented Feb 13 at 21:37
  • 1
    For comparison: in Linux one can discard an arbitrary fragment of a device by using blkdiscard with --offset and --length (small enough --step may be needed). If you are not sure if Windows has TRIMmed what you wanted, using blkdiscard from a live Linux distro is a feasible workaround; not very convenient, but it's a one-time operation. On the other hand blkdiscard will happily do what you tell it to do (as opposed to what you want it to do), regardless of existing partitions and filesystems, so you are one typo (or one brain fade) away from a disaster where you lose data. Commented Feb 14 at 7:33

4 Answers 4

-1

Unformatted space, like what you see when you shrink your partition, is separate from overprovisioned capacity. The OS cannot see overprovisioned areas, and the SSD will not automatically use unformatted (shrunk) space for overprovision tasks.

Some manufacturers do have tools to adjust the amount of space used for OP, like Samsung Magician for their SSDs. Each manufacturer sets aside a different amount of OP space on the disk (usually 5-10%) that you never see. You do not need to add more space to it.


SSD TRIM has no purpose on unformatted areas of your disk

5
  • 7
    I disagree. You can overprovision that way, does not matter OS can't see overprovisioning at firmware level or even HPA like areas. And trimming this area will cause associated LBA addresses to be un-mapped. Commented Feb 13 at 21:34
  • 4
    And since you will leave the space unpartitioned the LBA range remains un-mapped and is thus available for over provisioning. SSD tools that offer a overprovision configuration option (in addition to firmware level overprovisioning) do pretty much the same it's just they hide the space by for example utilizing ATA HPA area option. Commented Feb 13 at 21:43
  • 7
    This is technically accurate, but ignores the reality that any space not being used in the logical block mapping the OS sees is functionally also overprovisioning space for the FTL. SSDs are not like hard drives, they don’t have a fixed default block mapping and remap when a given block goes bad, they behave like thinly-provisioned storage with CoW semantics for blocks and a larger backing store than their presented size. Any unused physical block can be used for any newly written logical block, irrespective of location. Commented Feb 14 at 12:20
  • 5
    And that in turn means that any space not being used at the logical block level translates to extra physical blocks that the FTL can use for wear-leveling, which in turn gives you better life expectancy for the SSD. Commented Feb 14 at 12:21
  • 1
    "SSD TRIM has no purpose on unformatted areas of your disk"... what? Wouldn't it make those blocks available for wear-leveling?
    – user541686
    Commented Feb 14 at 14:59
14

I think what OP means to do is reserve for example 10% of LBA space and not do anything with it so the drive can use it for overprovisioning. By making certain this area is trimmed you'd be certain this piece of LAB space isn't mapped to any physical NAND real-estate. If you then refrain from writing data to this area, the LBA space remains un-mapped.

I do data recovery and have observed:

  • Deleting a partition using Disk Management does not trigger TRIM, IOW data remains recoverable (demonstration).
  • Creation of a new partition + new file system in this unallocated space triggers TRIM for this area (IOW the LBA range is un-mapped). This is as OP assumes, vital because before the firmware can use this space as it pleases it has to be made aware of this. TRIM is the command to communicate this to the controller/firmware. If you want to use this space purely for overprovisioning it may be a good idea to then simply delete the partition again.

Over-provisioned space is simply a percentage of NAND real-estate that isn't mapped to LBA. It does not matter whether this space is maintained at firmware level, by means of some sort of HPA area (this is basically what manufacturer tools that offer an over-provisioning configuration option do) or that it's set aside by the user for this purpose. The only difference is that the latter does not hide the area like HPA (host protected area) for example does. However, by leaving/making the space unallocated after you have it trimmed, you prevent from new data being written to it.

Alternatively, you can set a HPA area (on a still unused or empty drive) using for example hdparm. It's essentially the same idea: Any region of the SSD that's not mapped to LBA will act as overprovisioned space.

You can not count on writing zeros to the area. Although trimmed LBA space usually returns zeros when you read from it, this is purely the firmware simply returning zeros since it detects user is trying to read from un-mapped LBA. This is different than actually writing zeros (although on modern SSDs firmware may detect zeros and not actually allocate physical NAND to store these, but this is a different topic).

Any overprovisioning will contribute to for example prolonging SSD life time. One manufacturer trick to offer higher quality SSDs with for example increased endurance, is simply increasing over-provisioned space at firmware level.

4
  • 3
    Would you mind highlighting "Creation of a new partition in this unallocated space triggers TRIM" as that's the part which directly answers OP's question? (Q: How do I trigger TRIM? A: Create a new dummy partition there (and delete it afterwards).)
    – TooTea
    Commented Feb 14 at 9:19
  • Thanks for your comment, will do. Commented Feb 14 at 13:53
  • Is it "creation of a new partition" or "formatting of that partition" that triggers TRIM? I don't know the answer, but I have my suspicions that creating an unformatted partition will not TRIM it; but it is TRIM-ed before formatting, which could still be somewhat useful, but this actually writes the filesystem metadata and leaves it there. Commented Jul 7 at 22:10
  • It's good you question me on this. I think TRIM is not triggered by partition table operation only. I will correct the answer. Commented Jul 7 at 23:14
0

If I had to do it, I would boot a Linux LiveUSB, create an empty partition there, blkdiscard it, then remove the partition. This is the most direct way to do exactly what you want. But if you're not very familiar with Linux partitioning tools, then there's a high chance you can destroy something else instead, so I wouldn't recommend this as the go-to method for everyone.

The next best option is what Joep van Steen suggested: create a new partition, "QUICK"-FORMAT IT AS NTFS, then delete the partition. You'll have the NTFS metadata written there, but it's most likely very little compared to what you have there now.

I can not be completely sure that Windows does not TRIM an empty partition upon creation, or that it does not TRIM other filesystems. But it is highly likely that it doesn't, and it most certainly does TRIM NTFS before formatting it.

-1

An SSD is less vulnerable to reading unallocated disk areas, with a good chance that doing so will retrieve only zeros.

If you worry about the data that was previously on this space, and would like to take no chances, I can see two solutions:

  • Get a disk editor product and zero out the unoccupied space. This is unsafe since you would need to calculate sector offsets and a mistake could be costly.

  • Create a partition over the unoccupied space and zero out the partition with some utility, or copy to it one or several large files that will terminate with an insufficient space message. Deleting the written files, once they fill out the partition, will certainly do the TRIM

The second option is much more practical.

2
  • 5
    OP's goal is to trigger a TRIM on the unused part of the disk (telling the SSD firmware the region no longer contains useful data). Writing zeroes (or anything else) is not going to achieve that goal, the SSD will think those zeroes are useful and should be remembered.
    – TooTea
    Commented Feb 14 at 8:25
  • @TooTea: Deleting the written files, once they fill out the partition, will certainly do the TRIM. I forgot to write it in the answer, now added.
    – harrymc
    Commented Feb 14 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .