Forcing TRIM on the entire free space of an SSD drive

Discussion in 'hardware' started by homeless_sapient, Mar 4, 2013.

Thread Status:
Not open for further replies.
  1. homeless_sapient

    homeless_sapient Registered Member

    Joined:
    Apr 11, 2012
    Posts:
    34
    Hi! I wonder whether it is a good idea to periodically force a global trimm on the entire free space of an SSD drive. For example with this batch script:

    ---------------------------------------------------------------------------
    @setlocal enableextensions enabledelayedexpansion
    @echo off
    for /f "tokens=3" %%a in ('dir c:\') do (
    set bytesfree1=%%a
    )
    set bytesfree1=%bytesfree1:,=%
    echo FREE SPACE: %bytesfree1%
    endlocal && set bytesfree1=%bytesfree1%
    fsutil file createnew 000 %bytesfree1%
    for /f "tokens=3" %%a in ('dir c:\') do (
    set bytesfree2=%%a
    )
    set bytesfree2=%bytesfree2:,=%
    echo FREE SPACE: %bytesfree2%
    endlocal && set bytesfree2=%bytesfree2%
    timeout /t 3
    del 000
    for /f "tokens=3" %%a in ('dir c:\') do (
    set bytesfree3=%%a
    )
    set bytesfree3=%bytesfree3:,=%
    echo FREE SPACE: %bytesfree3%
    endlocal && set bytesfree3=%bytesfree3%
    ---------------------------------------------------------------------------

    This script:
    1) checks the free space in the drive
    2) creates a sparse file with the size of the free space
    (this sparse file fills the free space of the drive)
    3) deletes the sparse file to invoke a trim command for the entire free space of the drive.

    I've checked the efficieny of this script with the trimcheck program (http://files.thecybershadow.net/trimcheck/), and it seems ok:

    1) disable trim:
    fsutil behavior set disabledeletenotify 1
    2) run the trimcheck program
    3) enable trim:
    fsutil behavior set disabledeletenotify 0
    4) run the above mentioned script
    5) wait several minutes
    6) run again the trimcheck program to check the trim. For me it's ok: the data is empty (00 00 00…)

    What is your opinion? Is this unnecessary, or something unsafe, detrimental, or useful?
     
  2. Bill_Bright

    Bill_Bright Registered Member

    Joined:
    Jun 29, 2007
    Posts:
    2,271
    Location:
    Nebraska, USA
    I think there are too many unknown variables to make this useful for most users.

    Not all SSDs are created equal. This is especially true when comparing early SSDs to today's SSDs. Today's SSDs are much less susceptible to the woes of early SSDs.

    Windows 7 and 8 detect SSDs and "should" have TRIM enabled automatically. This can easily be verified with the string you noted by running from a command prompt:
    fsutil behavior query DisableDeleteNotify​
    If a "0" is returned, TRIM is enabled.

    Users of non-supporting operating systems will have other issues.

    I am inclined to trust the SSD makers to know how to keep their SSDs optimized - at least with current generation SSDs and a modern OS.

    I am not inclined to "force" anything, unless "normal" procedures fail.
     
  3. mechBgon

    mechBgon Registered Member

    Joined:
    Mar 2, 2013
    Posts:
    68
    Location:
    USA
    I have Win8 Pro on my three SSD-equipped systems and content myself with scheduling its native "Optomize" routine to run daily, which in the case of SSDs it gives them a TRIM. On Win7, I was just letting the drive handle it on its own timetable.

    On the subject of SSD performance, most hardware enthusiasts are already aware they should have their SATA controllers in AHCI mode. But I've also seen performance improvements (in benchmarks, anyway) from setting the motherboard's BIOS to make them Hot Swap in addition. If you're looking for a modest performance increase in benchmarks, give that a try. It shouldn't upset your OS installation, and is simple to reverse.
     
Loading...
Thread Status:
Not open for further replies.