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.7k 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.
    • stephenw10S
      stephenw10 Netgate Administrator
      last edited by

      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

        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

          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

            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

              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

                @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

                  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
                  • arrmoA
                    arrmo
                    last edited by

                    Hi,

                    Sorry, trying this on v2.2, not sure if I'm doing something wrong, but here is what I get …
                    Entered: tunefs -t enable /

                    Then the result is ...
                    tunefs: issue TRIM to the disk set
                    tunefs: /: failed to write superblock

                    And checking tunefs (tunefs -p /) ... nope, it's still off. Thoughts?

                    Thanks!

                    1 Reply Last reply Reply Quote 0
                    • 3
                      3vian
                      last edited by

                      @arrmo:

                      Hi,

                      Sorry, trying this on v2.2, not sure if I'm doing something wrong, but here is what I get …
                      Entered: tunefs -t enable /

                      Then the result is ...
                      tunefs: issue TRIM to the disk set
                      tunefs: /: failed to write superblock

                      And checking tunefs (tunefs -p /) ... nope, it's still off. Thoughts?

                      Thanks!

                      arrmo - It sounds like you are not in Single User Mode. Reboot and at the boot screen use option 5 and enter /sbin/tunefs -t enable / at the prompt and reboot (using /sbin/reboot).

                      3vian

                      1 Reply Last reply Reply Quote 0
                      • arrmoA
                        arrmo
                        last edited by

                        Will do, thanks! Saw that part, wasn't sure if it was key … seems it is ...  ;)

                        This setting is permanent (when done this way), right?

                        Thanks again.

                        1 Reply Last reply Reply Quote 0
                        • E
                          eSpezi
                          last edited by

                          Hi Everybody,

                          I also have the 5018A-FTN4  with a SSD and would like to turn on TRIM.
                          Unfortunately I am not able to enter the Single User Mode to turn it on, as it gives me a
                          panic: AP #1 (PHY# 2) failed!

                          @3vian: You seem to have gotten it to work. How did you manage to get into the Single User Mode?

                          It would also be very handy to start a "best practices for installing pfSense on a 5018A-FTN4 thread", as they seem to become very popular, with all the relevant BIOS settings.
                          Some pfSense tweaks are already mentioned here: https://forum.pfsense.org/index.php?topic=75015.0

                          As always: thank you very much for any info!
                          Harry

                          1 Reply Last reply Reply Quote 0
                          • K
                            kejianshi
                            last edited by

                            Just imagine the day when there is a simple check box for "Enable Trim" in a system menu…

                            Alot to ask, I know but we can dream right?

                            1 Reply Last reply Reply Quote 0
                            • S
                              Synthetickiller
                              last edited by

                              @3vian:

                              @arrmo:

                              Hi,

                              Sorry, trying this on v2.2, not sure if I'm doing something wrong, but here is what I get …
                              Entered: tunefs -t enable /

                              Then the result is ...
                              tunefs: issue TRIM to the disk set
                              tunefs: /: failed to write superblock

                              And checking tunefs (tunefs -p /) ... nope, it's still off. Thoughts?

                              Thanks!

                              arrmo - It sounds like you are not in Single User Mode. Reboot and at the boot screen use option 5 and enter /sbin/tunefs -t enable / at the prompt and reboot (using /sbin/reboot).

                              3vian

                              I appreciate this post.

                              I came into all of this being a n00b w/ command line, so if I overlooked something simple, be gentle.

                              I've tried everything & can't seem to get anything working.

                              Here's what I've done after upgrading to 2.1.5 (SSD is an intel 320 160gb, has TRIM):

                              1. Logged in as single user (selected 5), but there seems to be a slight issue with the mount & asking me to specify a path while booting. I can provide that info later on. Anyways, I tell it to skip that & it loads up pfsense perfectly, everything works. Loads fine with multi-user.

                              2. Input what you said & got this:

                              [2.1.5-RELEASE][root@pfsense.router]/root(10): /sbin/tunefs -t enable /
                              tunefs: issue TRIM to the disk set
                              tunefs: /dev/ufsid/53f426d4c691b578: failed to write superblock

                              I can log in as root or admin & I get the same response. Other responses to things I've tried from this thread include "bad trim" &  one other statement I forgot to write down.

                              I'm tempted to reinstall from scratch as it doesn't take that long to do & try again. I've been down that road, but I wonder if going back to a pre "/usr/local/sbin/ufslabels.sh" point in time may help as that seems to change the characteristics of the drive.

                              Also, this line always trips me up: ahci_load="YES" to /boot/loader.conf.local

                              [2.1.5-RELEASE][root@pfsense.router]/root(33): /boot/loader.conf.local ahci_load="Yes"
                              /boot/loader.conf.local: Permission denied.

                              Thoughts?

                              1 Reply Last reply Reply Quote 0
                              • stephenw10S
                                stephenw10 Netgate Administrator
                                last edited by

                                That's not something you run at the command line. You have to add the line:
                                ahci_load="YES"
                                to the file  /boot/loader.conf.local
                                You can do the using the webgui in Diagnosics: Edit File: or from the command line using the built in ee editor (or vi if you're a masochist!).

                                Steve

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post
                                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.