How to Trim SSD in Windows 10

TRIM is a special ATA command which was developed to keep the performance of your SSD drives at peak performance for the duration of your SSD's life. TRIM tells the SSD controller to erase invalid and not used data blocks from the storage in advance, so when a write operation happens, it finishes faster because no time is spent in erase operations. Without TRIM automatically working at the system level, your SSD performance will degrade over time unless you manually use a tool which can send the TRIM command to it.

By default, TRIM is enabled for all SSDs. However, it is a good idea to check if TRIM is correctly enabled for your SSD in Windows 10 before proceeding. Refer to the following article:

Advertisement

How to see if TRIM is enabled for SSD in Windows 10

In Windows 10, TRIM is supported for both NTFS and ReFS file systems. If it is disabled, you can enable it manually. After that, you might want to TRIM your SSD manually. In Windows 10, this can be with PowerShell.

To Trim an SSD in Windows 10, you need to use the Optimize-Volume cmdlet.

The Optimize-Volume cmdlet optimizes a volume, performing defragmentation, trim, slab consolidation, and storage tier processing. If no parameter is specified, then the default operation will be performed per the drive type as follows.

  • HDD, Fixed VHD, Storage Space. -Analyze -Defrag.
  • Tiered Storage Space. -TierOptimize.
  • SSD with TRIM support. -Retrim.
  • Storage Space (Thinly provisioned), SAN Virtual Disk (Thinly provisioned), Dynamic VHD, Differencing VHD. -Analyze -SlabConsolidate -Retrim.
  • SSD without TRIM support, Removable FAT, Unknown. No operation.

In our case, we need to pass the -ReTrim argument to the cmdlet to start the Trim operation. The syntax is as follows.

Optimize-Volume -DriveLetter YourDriveLetter -ReTrim -Verbose

Replace the YourDriveLetter portion with your solid state drive partition letter.

Open an elevated PowerShell and type the command above. The letter of my SSD drive is F, so my command looks as follows.

Optimize-Volume -DriveLetter F -ReTrim -Verbose

Windows 10 Trim Ssd

When finished, close the PowerShell window.

The cmdlet will generate TRIM and Unmap hints for all currently unused sectors of the volume, notifying the underlying storage that the sectors are no longer needed and can be purged.

This can recover unused capacity on thinly provisioned drives.

 

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

Advertisment

11 thoughts on “How to Trim SSD in Windows 10

  1. PB

    Or just use the defrag tool built into Windows 10. The Optimise button carries out TRIM command on SSD and Defrag on non-SSD HDD.

    Reply
  2. Kris

    When executing the command in the post, I get the error ‘Optimize-Volume’ is not recognized as an internal or external command, operable program or batch file.

    Running Windows 10 Enterprise. You’d think that Windows 10 is Windows 10, but (of course) that is not the case.

    Typical Windows /rolleyes.

    Reply
    1. Ruben

      So basically you opened >cmd< and didnt get it to work and blame windows?
      You'd think that Windows 10 users would be able to follow written instructions, but (of course) that is not the case.

      Typical Kris /rolleyes.

      Sarcasm aside, try powershell and not cmd.

      Reply
    2. jay

      dear roll-eyes,
      Please don’t assume.
      I did execute a power shell – but not as admin and got permission error
      Started powershell as admin and got
      ‘OptimizeVolume’ is not recognized as an internal or external command…

      here is copy and paste from window

      Windows PowerShell
      Copyright (C) Microsoft Corporation. All rights reserved.

      Try the new cross-platform PowerShell https://aka.ms/pscore6

      PS C:\WINDOWS\system32> OptimizeVolume -Driveletter C -ReTrim -Verbose
      OptimizeVolume : The term ‘OptimizeVolume’ is not recognized as the name of a cmdlet, function, script file, or
      operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
      again.
      At line:1 char:1
      + OptimizeVolume -Driveletter C -ReTrim -Verbose
      + ~~~~~~~~~~~~~~
      + CategoryInfo : ObjectNotFound: (OptimizeVolume:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

      PS C:\WINDOWS\system32>

      Reply
      1. Warren

        It looks like you missed a character when typing that.
        In PowerShell, it is typical to see a verb-noun syntax. So, you’ll type Optimize-Volume. You NEED the – in between Optimize and Volume.

        Reply
  3. Mikac

    you can use CMD to call PS and run TRIM command:

    powershell -executionpolicy bypass Optimize-Volume -DriveLetter C -ReTrim -Verbose

    Reply
    1. Jay

      This worked for me.
      T H A N K Y O U !!

      Reply
  4. thierrybo

    As all my searches to change a HDD to SDD win windows 10 did not succeeded,
    This page is useful because at least I can trim the disk manually :

    PS C:\WINDOWS\system32> Optimize-Volume -DriveLetter G -ReTrim -Verbose
    COMMENTAIRES : Invocation de réoptimisation sur KINGSTON_SSD_A400 (G:)…
    COMMENTAIRES : Réoptimisation : 0 % effectués…
    COMMENTAIRES : Réoptimisation : 100 % effectués.
    COMMENTAIRES : Passe 1 :
    COMMENTAIRES : Réoptimisation : 48 % effectués…
    COMMENTAIRES : Réoptimisation : 56 % effectués…
    COMMENTAIRES : Réoptimisation : 63 % effectués…
    COMMENTAIRES : Réoptimisation : 69 % effectués…
    COMMENTAIRES : Réoptimisation : 74 % effectués…
    COMMENTAIRES : Réoptimisation : 81 % effectués…
    COMMENTAIRES : Réoptimisation : 89 % effectués…
    COMMENTAIRES : Réoptimisation : 97 % effectués…
    COMMENTAIRES : Réoptimisation : 99 % effectués…
    COMMENTAIRES : Réoptimisation : 100 % effectués.
    COMMENTAIRES :
    Post Defragmentation Report:
    COMMENTAIRES :
    Informations sur le volume :
    COMMENTAIRES : Taille du volume = 223,44 Go
    COMMENTAIRES : Taille du cluster = 4 Ko
    COMMENTAIRES : Espace utilisé = 119,79 Mo
    COMMENTAIRES : Espace libre = 223,32 Go
    COMMENTAIRES :
    Réoptimisation :
    COMMENTAIRES : Allocations sauvegardées = 223
    COMMENTAIRES : Allocations optimisées = 221
    COMMENTAIRES : Espace total optimisé = 220,92 Go
    PS C:\WINDOWS\system32>

    Reply
    1. Rajan Patel

      You can’t “change” a HDD into an SSD. Unless you’re referring to the action of physically removing the HDD and installing a SSD in it’s place. In which case it’s pretty much that.

      Reply
  5. G

    I get a blinking cursor, at that time you can’t write anything. Then get a lot of red text and error messages, after a few seconds, that he can’t do ….. Trim volume etc etc.

    Reply
  6. bursto7

    i try to retrim my refs volume which is mount from SAN thin disk. i can see any space reclaim after running retrim cmd. So does refs support reclaiming space through the retrim command?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *