Trim for SSD



  • Hello all,

    I am running a 64GB sandisk SSD as my pfsense boot drive, it is quick and so far very happy with it. I know how to enable trim in Windows but how do I do it in pfsense?  8)
    I am running the latest version of pfsense.



  • Chances are that you don't actually need TRIM. If the filesystems are not really full the disk will have large amounts of unused space that the wear leveling system can use.



  • Ohhhh - I'd turn on TRIM.





  • Fro above  https://forum.pfsense.org/index.php?topic=66622.0

    jeppe67 says

    It´s very simple to add TRIM to SSD disks now, it´s just hard to find out how in the first place.
    Here´s what I did today:
    Login with SSH and open the shell.
    Run /usr/local/sbin/ufslabels.sh
    Add the line ahci_load="YES" to /boot/loader.conf.local
    reboot the machine
    Login with SSH and open the shell
    touch /root/TRIM_set; /etc/rc.reboot

    Once the machine has rebooted check the status with: tunefs -p /
    [2.1-RELEASE][admin@pfSense.hemma]/root(1): tunefs -p /
    tunefs: POSIX.1e ACLs: (-a)                                disabled
    tunefs: NFSv4 ACLs: (-N)                                  disabled
    tunefs: MAC multilabel: (-l)                              disabled
    tunefs: soft updates: (-n)                                disabled
    tunefs: gjournal: (-J)                                    disabled
    tunefs: trim: (-t)                                        enabled
    tunefs: maximum blocks per file in a cylinder group: (-e)  2048
    tunefs: average file size: (-f)                            16384
    tunefs: average number of files in a directory: (-s)      64
    tunefs: minimum percentage of free space: (-m)            8%
    tunefs: optimization preference: (-o)                      time
    tunefs: volume label: (-L)

    How do I do "Login with SSH and open the shell"?



  • @kpa:

    Chances are that you don't actually need TRIM. If the filesystems are not really full the disk will have large amounts of unused space that the wear leveling system can use.

    I play with trim and at the end I discovered that my ssd does not support trim function, on the other hand use tunefs bribed me the partition, and I had to reinstall the pfs.

    Good luck…



  • I us SLC in mine with no trim

    Most people don't want to buy that.  Do you have an SLC drive also?



  • Re install - that does not sound good at all.
    but I use a recent Sandisk 64GB SSD as my boot drive - does that 'qualify' for no need for trim?
    It is this one  https://www.amazon.co.uk/SanDisk-SSD-Sata-2-5-inch-Internal/dp/B007ZWLRSU



  • If its an MLC or TLC drive it more than likely supports and needs TRIM.



  • @Babiz:

    @kpa:

    Chances are that you don't actually need TRIM. If the filesystems are not really full the disk will have large amounts of unused space that the wear leveling system can use.

    I play with trim and at the end I discovered that my ssd does not support trim function, on the other hand use tunefs bribed me the partition, and I had to reinstall the pfs.

    Good luck…

    You reinstalled for no good reason, you could have just turned TRIM off by booting into the single user mode and turning it off with tunefs.



  • My SSD is as I have posted before? So do I have to trim the SSD or leave it as is?



  • I couldn't find a spec on it.  Not a complete spec anyway.



  • @Waqar.UK:

    My SSD is as I have posted before? So do I have to trim the SSD or leave it as is?

    • create a configuration backup (.xml file)

    • prepare a USB stick to boot and install from it

    • read this post How to enable TRIM

    • and it will be done in several minutes

    • otherwise you could reinstall it fast and play back the configuration backup!



  • @BlueKobold:

    @Waqar.UK:

    My SSD is as I have posted before? So do I have to trim the SSD or leave it as is?

    • create a configuration backup (.xml file)

    • prepare a USB stick to boot and install from it

    • read this post How to enable TRIM

    • and it will be done in several minutes

    • otherwise you could reinstall it fast and play back the configuration backup!

    What do I create a USB stick from?
    since I have a working stable (latest) pfsense setup - I cannot understand why I need to install again.
    I have a backup of my configuration file (xml file).



  • @kpa:

    Chances are that you don't actually need TRIM. If the filesystems are not really full the disk will have large amounts of unused space that the wear leveling system can use.

    so the SDD just does this automatically?  Im putting together my first system, just ordered a Kingston SSDNow V+200 90GB SATA III 6Gb/s 2.5" Solid State Drive SVP200S3/90G.

    just trying to determine if i need to enable trim or not (this will be my first pfsense device).  are we presented with the option during install?



  • @opticalc:

    @kpa:

    Chances are that you don't actually need TRIM. If the filesystems are not really full the disk will have large amounts of unused space that the wear leveling system can use.

    so the SDD just does this automatically?  Im putting together my first system, just ordered a Kingston SSDNow V+200 90GB SATA III 6Gb/s 2.5" Solid State Drive SVP200S3/90G.

    just trying to determine if i need to enable trim or not (this will be my first pfsense device).  are we presented with the option during install?

    All SSDs have automatic wear leveling. What TRIM does is to mark disk blocks that are no longer in use as empty so that the wear leveling has more free space to play with. If your disks are mostly empty the wear leveling will never come to a situation where the unused blocks become scarce and there's no reason to enable TRIM.



  • I sse where you come from. My sandisk 64GB SSD only uses less than 4GB for my pfsense system.


Log in to reply