• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

V2.1 - Enabling TRIM for SSD users

Scheduled Pinned Locked Moved Problems Installing or Upgrading pfSense Software
30 Posts 18 Posters 24.8k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    jeppe67
    last edited by Sep 17, 2013, 1:42 PM

    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)

    All done I guess

    1 Reply Last reply Reply Quote 0
    • J
      jasonlitka
      last edited by Sep 17, 2013, 5:20 PM

      @Sn3ak:

      It's not sufficient to use the steps mentioned above. You also need to be using the ahci module, unless something changed in a later snap.

      see: http://forum.pfsense.org/index.php/topic,63656.0.html

       add ahci_load="YES" to /boot/loader.conf.local 
      

      See #20 for a way to convert you to ufslabels so that changing from ad* to ada* doesn't break your boot.

       
      The AHCI module should be included in snapshots now (I just updated a VM and checked, it's there).
      
      Also look at /usr/local/sbin/ufslabels.sh - that would eliminate the need to make any fstab edits.
      
      Too late for 2.1 to grow an installer option for it, but perhaps for 2.2.
      
      

      My tunefs shows trim enabled without anything but the command in the first post.

      I can break anything.

      1 Reply Last reply Reply Quote 0
      • S
        stan-qaz
        last edited by Sep 17, 2013, 6:51 PM

        I'm seeing the trim not enabled warning in my dmesg output.

        I'm hesitant to break my pfSense box by poking at things I don't really understand and looking at the other topic I'm not seeing disk labels like they are discussing. Mine are /dev/ad12sla and /dev/ad12slb will the conversion script deal with these properly?

        Adding to me hesitation, what impact will this have for the next update, will I have to find this info and make the changes again? If I do an update with this in place will it break my box?

        Is enabling trim worth the risk of making these changes?

        I really wish I had an SSD in my test box, that would be less scary than running these on my live system.

        1 Reply Last reply Reply Quote 0
        • R
          rjcrowder
          last edited by Sep 17, 2013, 8:11 PM

          Above steps worked fine for me… on two different boxes.

          1 Reply Last reply Reply Quote 0
          • K
            kejianshi
            last edited by Sep 17, 2013, 8:52 PM

            stan-qaz - I think it really depends on the SSD.

            Oddly enough, if you get a 2008/2009ish SLC SSD which run about $50 on ebay, those work well without incident for me (so far) without TRIM.

            If you get a 2010/2011ish MLC SSD without TRIM, you might get trouble in short order.

            If you get a newer 2013ish small MLC SSD with a newer sandforce controller and newer highly durable garbage collection you again would probably be OK.  (According to specs anyway)

            In all scenarios with MLC, your are far better off with TRIM than without.

            1 Reply Last reply Reply Quote 0
            • S
              stan-qaz
              last edited by Sep 18, 2013, 12:07 AM

              I ran the  command and got the following, the "swapoff invalid" argument is worrisome. I'm not feeling really confident so I did a backup of my original fstab in hopes that if I need it I can somehow replace it.

              [2.1-RELEASE][root@pfsense.home]/root(6): /usr/local/sbin/ufslabels.sh                                                                                                          
              FS: / on device ad12s1a with ufsid 50f89405e017f40f                                                                                                                             
              FS: Swap on device ad12s1b                                                                                                                                                      
              ====================                                                                                                                                                            
              Current fstab:                                                                                                                                                                  
              # Device                Mountpoint      FStype  Options         Dump    Pass#                                                                                                   
              /dev/ad12s1a            /               ufs     rw,noatime              1       1                                                                                               
              /dev/ad12s1b            none            swap    sw              0       0                                                                                                       
              ====================                                                                                                                                                            
              New fstab:                                                                                                                                                                      
              # Device                Mountpoint      FStype  Options         Dump    Pass#                                                                                                   
              /dev/ufsid/50f89405e017f40f             /               ufs     rw,noatime              1       1                                                                               
              /dev/label/swap         none            swap    sw              0       0                                                                                                       
              Commit changes? (y/n):                                                                                                                                                          
              y                                                                                                                                                                               
              Disabling swap to apply label                                                                                                                                                   
              swapoff: /dev/ad12s1b: Invalid argument                                                                                                                                         
              Applying label to swap parition                                                                                                                                                 
              Activating new fstab                                                                                                                                                            
              Re-enabling swap 
              

              Added the load module line and I'm going to reboot once I've downloaded the 2.1 boot CD.

              1 Reply Last reply Reply Quote 0
              • S
                stan-qaz
                last edited by Sep 18, 2013, 12:55 AM

                It seems to have worked, no obvious error messages. My dmesg output for the SSD is now looking like this:

                
                ada0 at ahcich2 bus 0 scbus2 target 0 lun 0                                                                                                                                     
                ada0: <m4-ct064m4ssd2 040h="">ATA-9 SATA 3.x device                                                                                                                               
                ada0: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)                                                                                                                    
                ada0: Command Queueing enabled                                                                                                                                                  
                ada0: 61057MB (125045424 512 byte sectors: 16H 63S/T 16383C)</m4-ct064m4ssd2> 
                

                I'll print out a cheat sheet for this just in case. :-)

                1 Reply Last reply Reply Quote 0
                • T
                  Taigar
                  last edited by Nov 16, 2013, 6:41 PM

                  @Sn3ak:

                  It's not sufficient to use the steps mentioned above. You also need to be using the ahci module, unless something changed in a later snap.

                  see: http://forum.pfsense.org/index.php/topic,63656.0.html

                   add ahci_load="YES" to /boot/loader.conf.local 
                  

                  See #20 for a way to convert you to ufslabels so that changing from ad* to ada* doesn't break your boot.

                   
                  The AHCI module should be included in snapshots now (I just updated a VM and checked, it's there).
                  
                  Also look at /usr/local/sbin/ufslabels.sh - that would eliminate the need to make any fstab edits.
                  
                  Too late for 2.1 to grow an installer option for it, but perhaps for 2.2.
                  
                  

                  I don't know if I have to start a new topic, or can reply here.

                  I also am trying to enable TRIM, and tried the following steps

                  http://forum.pfsense.org/index.php/topic,63656.msg344604.html#msg344604

                  But I don't understand step 6.

                  When I reboot the system, I can choose to escape to loader prompt by pressing '7'

                  Is that correct or do I have to do something else?
                  Do I even need to do all those steps?

                  My motherboard is Supermicro X7SP-HF-D525 and I am using an Intel 320 series SSD.

                  1 Reply Last reply Reply Quote 0
                  • M
                    MediocreFred
                    last edited by Dec 8, 2013, 7:30 PM

                    Thanks very much for consolidating all of the steps into one easily followable list! Worked perfectly!

                    @jeppe67:

                    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)

                    All done I guess

                    1 Reply Last reply Reply Quote 0
                    • R
                      Ramosel
                      last edited by Feb 10, 2014, 1:52 AM Feb 10, 2014, 1:45 AM

                      Had to go back and re-read some of these posts regarding "Trim" to answer a question for a friend.

                      Any chance this (TRIM_set) will become an advanced system setup checkbox on an upcoming release??  I mean SSDs are becoming "de rigueur" and the release of FreeBSD now being employed does support the Trim command.  I'll ask nicely…. PLEASE?

                      edit:  I'll be greedy while I'm asking...  also have it be an installation setup option?

                      Rick

                      1 Reply Last reply Reply Quote 0
                      • H
                        Hugovsky
                        last edited by Feb 25, 2014, 9:23 PM Feb 25, 2014, 9:21 PM

                        @Jason:

                        @Sn3ak:

                        It's not sufficient to use the steps mentioned above. You also need to be using the ahci module, unless something changed in a later snap.

                        see: http://forum.pfsense.org/index.php/topic,63656.0.html

                         add ahci_load="YES" to /boot/loader.conf.local 
                        

                        See #20 for a way to convert you to ufslabels so that changing from ad* to ada* doesn't break your boot.

                         
                        The AHCI module should be included in snapshots now (I just updated a VM and checked, it's there).
                        
                        Also look at /usr/local/sbin/ufslabels.sh - that would eliminate the need to make any fstab edits.
                        
                        Too late for 2.1 to grow an installer option for it, but perhaps for 2.2.
                        
                        

                        My tunefs shows trim enabled without anything but the command in the first post.

                        Exactly the same to me. Disk used:

                        Model Family:    SandForce Driven SSDs
                        Device Model:    KINGSTON SV300S37A60G

                        2.1-RELEASE (amd64)
                        built on Wed Sep 11 18:17:34 EDT 2013
                        FreeBSD 8.3-RELEASE-p11

                        Platform: nanobsd (4g)

                        1 Reply Last reply Reply Quote 0
                        • J
                          jideel
                          last edited by Apr 4, 2014, 2:54 PM

                          Hello,
                          I managed to enable TRIM on a Samsung 840 Pro SSD, but not so simply.
                          The appliance used is a Teak 5020. By default AHCI is not enabled in the bios, and i used ufslabels.sh before enabling AHCI in the bios.
                          After, ufsid was set but the TRIM_set trick was not working.
                          I enabled AHCI, rebooted, then after started in single user mode, issued '/sbin/mount', and then "/sbin/tunefs -t enable /dev/ufsid/533f10e87e412553" (adapt with your own ufsid).
                          Then "./tunefs -p /" returns well "tunefs: trim: (-t)      enabled".
                          However "camcontrol identity ada0" does not show that TRIM is enabled :
                          "data set management (TRIM)    yes    [empty]"
                          Any idea ?
                          Thank you

                          1 Reply Last reply Reply Quote 0
                          • C
                            cfipilot
                            last edited by Jul 2, 2014, 3:54 AM

                            I also have a samsung SSD and i cant enable trim.  Using the latest pfsense 2.1.4

                            Please help

                            1 Reply Last reply Reply Quote 0
                            • stephenw10S
                              stephenw10 Netgate Administrator
                              last edited by Jul 2, 2014, 4:34 AM

                              What have you tried? What was the result? What board is it connected to?

                              Steve

                              1 Reply Last reply Reply Quote 0
                              • C
                                cfipilot
                                last edited by Jul 2, 2014, 5:50 AM

                                added the following

                                Login with SSH or locally and open a shell
                                Run /usr/local/sbin/ufslabels.sh
                                Add ahci_load="YES" to /boot/loader.conf.local
                                Reboot

                                touch /root/TRIM_set; /etc/rc.reboot

                                When i try to boot in single user mode i get a kernel panic.

                                Hardware
                                Supermicro SuperServer 5018A-FTN4 with 16GB ECC ram. 
                                Samsung pro 120GB SSD.

                                pfsense 2.1.4

                                1 Reply Last reply Reply Quote 0
                                • stephenw10S
                                  stephenw10 Netgate Administrator
                                  last edited by Jul 2, 2014, 8:01 PM

                                  Did you set the SATA controller to AHCI mode in the BIOS?

                                  Steve

                                  1 Reply Last reply Reply Quote 0
                                  • Z
                                    zimba
                                    last edited by Jul 3, 2014, 1:21 AM

                                    You may try this instead in single user mode:

                                    /sbin/tunefs -t enable /

                                    After that reboot and then run tunefs -p /

                                    The touch /root/TRIM_set; /etc/rc.reboot has been removed in the newer version.

                                    1 Reply Last reply Reply Quote 0
                                    • arrmoA
                                      arrmo
                                      last edited by Jul 6, 2014, 12:49 AM

                                      Hi,

                                      Took a look, and it does seem that this allows enabling TRIM - that's great. But I do have a couple questions,

                                      • is there a way to check what the current state is?
                                      • if TRIM hasn't been on so far, is there a way to tell the SSD / BIOS to clean up the SSD?

                                      Thanks!

                                      1 Reply Last reply Reply Quote 0
                                      • 3
                                        3vian
                                        last edited by Jul 22, 2014, 3:21 PM

                                        @cfipilot:

                                        added the following

                                        Login with SSH or locally and open a shell
                                        Run /usr/local/sbin/ufslabels.sh
                                        Add ahci_load="YES" to /boot/loader.conf.local
                                        Reboot

                                        touch /root/TRIM_set; /etc/rc.reboot

                                        When i try to boot in single user mode i get a kernel panic.

                                        Hardware
                                        Supermicro SuperServer 5018A-FTN4 with 16GB ECC ram. 
                                        Samsung pro 120GB SSD.

                                        pfsense 2.1.4

                                        cfipilot - have you been able to get TRIM working? I have pretty much the same hardware except only using 8GB ECC RAM for now. I have a Samsung 840 Pro 120GB, is that what you are using?

                                        I wrote in another thread which was a bit newer (dealing with 2.1.1 as opposed to 2.1), but maybe the issue is hardware specific or it could just be my lack of FreeBSD knowledge…

                                        @3vian:

                                        I seem to have a problem with the TRIM enabled setting remaining after reboot.

                                        Once I executed /sbin/tunefs -t enable / what exactly should I do. I can't run /etc/rc.reboot because I get the following:

                                        lockf: cannot open /tmp/config.lock: Read-only file system
                                        Cannot reboot at this moment, a config write operation is in progress, and 30 seconds have passed
                                        

                                        If I just exit single-user mode then when restart and /sbin/tunefs -t enable / it indicates it is disabled.

                                        FYI - already added ahci_load="YES" to /boot/load.conf.local

                                        3vian

                                        1 Reply Last reply Reply Quote 0
                                        • 3
                                          3vian
                                          last edited by Jul 23, 2014, 9:06 AM

                                          cfipilot - Btw, I managed to get it enable.  See below.

                                          @3vian:

                                          Seems you have to use /sbin/reboot as mentioned below to reboot

                                          FYI - it should /sbin/tunefs -t enable /, not /sbin/tunefs -t / as mentioned below.

                                          @spid:

                                          @dstephens80:

                                          Charlie,

                                          I will give v2.2 a try and let you know how it goes.  As far as dmesg, I can provide nothing as the system will not boot with AHCI enabled.  it will not detect any GEOM devices, but it will boot fine if I remove the ahci_load="YES" from /boot/loader.conf.local.

                                          Did you convert fstab to ufslabel before adding ahci_load="YES" ?

                                          Run the following script to do it:
                                          /usr/local/sbin/ufslabels.sh

                                          then if it boots correctly go in single user mode and enable TRIM with:
                                          /sbin/tunefs -t /

                                          reboot with:
                                          /sbin/reboot

                                          and after a reboot check if it's enabled with:
                                          tunefs -p /

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                                            [[user:consent.lead]]
                                            [[user:consent.not_received]]