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

    Ahci(4) needed for TRIM

    2.1 Snapshot Feedback and Problems - RETIRED
    12
    42
    28.5k
    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.
    • AhnHELA
      AhnHEL
      last edited by

      Fantastic tutorial!!  Thanks Tikimotel and PTT   ;D

      Updated tutorial for the ahci_load="YES" to be edited into /boot/loader.conf.local

      That way it will persist through firmware updates because the /boot/loader.conf is overwritten during updates as well.

      For pfSense 2.1, Enable AHCI and TRIM for SSDs.
      
      1\.     Download the ISO of FreeBSD 8.3 and copy the "ahci.ko" into /boot/modules/
      
      2\.     chmod 0555 ahci.ko (r-xr-xr-x)
      
      3\.     Check if loads in the console, "kldload ahci" & "kldstat"
      
      4\.     Edit /boot/loader.conf.local to add ahci_load="YES"
      
      5\.     Reboot
      
      6\.     At the loader prompt "mountroot" type "?" for list of options.
      
      7\.     At the loader prompt "mountroot" type "ufs:/dev/ada0s1a" (ada0;ada1;ada4 will depend on chipset used)
      
      8\.     Once booted edit /etc/fstab and change and save the all mountpoints accordingly, including swap. (ada0;ada1;ada4 will depend on chipset used)
      
      9\.     Reboot
      
      pfSense will now boot like before if you have edited fstab correctly.
      
      10\.    Perform the TRIM_set action at a shell.
      
      						touch /root/TRIM_set; /etc/rc.reboot
      
      						to remove
      
      						touch /root/TRIM_unset; /etc/rc.reboot
      
      11\.    Reboot
      
      12\.    Check if TRIM is enabled with "tunefs -p /"
      

      AhnHEL (Angel)

      1 Reply Last reply Reply Quote 0
      • C
        charliem
        last edited by

        Great, worked right away!  I verified the module would load, then edited /etc/fstab, changing ad4 to ada0 and rebooted.  I got lucky: with my intel chipset, the SSD came up as ada0

        Maybe this should be in the release notes?  Or at least point to this thread in http://redmine.pfsense.org/issues/2319.  No use in documenting /root/TRIM_set if more work is needed to get TRIM working.

        Thanks again

        1 Reply Last reply Reply Quote 0
        • pttP
          ptt Rebel Alliance
          last edited by

          You can get the needed "ko" modules from here:

          FreeBSD 8.1: http://files.pfsense.org/jimp/ko-8.1/

          FreeBSD 8.3: http://files.pfsense.org/jimp/ko-8.3/

          Thanks goes to Jimp ;)

          Also say thanks to Jimp about the " xxxx.ko on the /boot/modules/" advice ;)

          http://forum.pfsense.org/index.php/topic,39595.msg205010.html#msg205010

          1 Reply Last reply Reply Quote 0
          • w0wW
            w0w
            last edited by

            Thanks jimp!  :D

            Looks like using rc.conf.local is not really needed, because during update rc.conf is edited, not deleted, so my things added into rc.conf years ago are still working. But to be safe… yes it's not bad to use rc.conf.local instead

            1 Reply Last reply Reply Quote 0
            • w0wW
              w0w
              last edited by

              
              smartctl 6.1 2013-03-16 r3800 [FreeBSD 8.3-RELEASE-p8 i386] (local build)
              Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
              
              /dev/: Unable to detect device type
              Please specify device type with the -d option.
              
              Use smartctl -h to get a usage summary
              
              

              I am getting this when trying to get S.M.A.R.T., after ahci enabled, any suggestions?

              1 Reply Last reply Reply Quote 0
              • C
                charliem
                last edited by

                @w0w:

                I am getting this when trying to get S.M.A.R.T., after ahci enabled, any suggestions?

                The device name changed with ahci, ie from ad4 to ada0 in my case, and the extra 'a' is not being picked up by the regexp in diag_smart.php

                This change to /usr/local/www/diag_smart.php will pick up the devices with the extra 'a', if it's there.

                
                --- diag_smart.php.orig 2013-06-27 22:25:23.000000000 -0400
                +++ diag_smart.php      2013-06-27 22:20:08.000000000 -0400
                @@ -277,7 +277,7 @@
                        default:
                        {
                                // Get all AD* and DA* (IDE and SCSI) devices currently installed and stores them in the $devs array
                -               exec("ls /dev | grep '^[ad][da][0-9]\{1,2\}$'", $devs);
                +               exec("ls /dev | grep '^[ad][da]a*[0-9]\{1,2\}$'", $devs);
                                ?>
                
                
                1 Reply Last reply Reply Quote 0
                • w0wW
                  w0w
                  last edited by

                  Thank you charliem!
                  Hmm, may be it should be submitted here - https://github.com/pfsense/pfsense/blob/master/usr/local/www/diag_smart.php ?

                  Or somebody can do the patch that can be applied with "Patches" package. This one posted does not look compatible.
                  I have patched manually but…

                  Patch works via "System Patches" package. Sorry  ;)

                  1 Reply Last reply Reply Quote 0
                  • T
                    Tikimotel
                    last edited by

                    Use with caution!
                    I've cleaned up the "patch" a bit and added one extra for the dashboard widget!  ;D

                    1st:
                    Description : "AHCI SMART fix"

                    
                    --- diag_smart.php.orig 2013-06-27 22:25:23.000000000 -0400
                    +++ diag_smart.php      2013-07-16 22:20:08.000000000 -0400
                    @@ -280,1 +280,1 @@
                    -               exec("ls /dev | grep '^[ad][da][0-9]\{1,2\}$'", $devs);
                    +               exec("ls /dev | grep '^[ad][da]a*[0-9]\{1,2\}$'", $devs);
                    
                    

                    Base Directory: "/usr/local/www/"
                    (Please test first!!! Line numbers may change or the patch may not be needed in the future!!!)

                    2nd (for dashboard widget)  ;)
                    Description : "ACHI dashboard fix"

                    
                    --- smart_status.widget.php.orig 2013-07-16 22:25:23.000000000 -0400
                    +++ smart_status.widget.php      2013-07-16 22:20:08.000000000 -0400
                    @@ -45,1 +45,1 @@
                    - exec("ls /dev | grep '^[ad][da][0-9]\{1,2\}$'", $devs); ## leant from orginal SMART status screen
                    + exec("ls /dev | grep '^[ad][da]a*[0-9]\{1,2\}$'", $devs); ## leant from orginal SMART status screen
                    
                    

                    Base Directory: "/usr/local/www/widgets/widgets/"
                    (Please test first!!! Line numbers may change or the patch may not be needed in the future!!!)

                    It works for me..

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

                      I think this is great, but TRIM on a SSD is so common like dirt by now and required, that it should either be:

                      1.  Something that is just automagically detected and applied (like it does for any other common device)

                      or

                      2.  Asked at initial install "would you like to enable TRIM on this device."

                      Maybe next decade.

                      1 Reply Last reply Reply Quote 0
                      • T
                        Tikimotel
                        last edited by

                        AHCI is great! for TCQ & NCQ on normal HDD's not just for TRIM on SSD's.
                        "ada0: Command Queueing enabled"

                        And for SATA 6Gbs support.
                        ada0: 600.000MB/s transfers (SATA 3.x, UDMA5, PIO 8192bytes)

                        1 Reply Last reply Reply Quote 0
                        • jimpJ
                          jimp Rebel Alliance Developer Netgate
                          last edited by

                          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.

                          Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                          Need help fast? Netgate Global Support!

                          Do not Chat/PM for help!

                          1 Reply Last reply Reply Quote 0
                          • AhnHELA
                            AhnHEL
                            last edited by

                            Thanks Jimp, just started a fresh installation on my main pf box using a new SSD and tried out the latest snap.  Works perfectly.

                            Couldnt figure out how to run the ufslabels.sh file.  Getting a permission denied at a shell, so just edited fstab the old fashioned way.

                            AhnHEL (Angel)

                            1 Reply Last reply Reply Quote 0
                            • jimpJ
                              jimp Rebel Alliance Developer Netgate
                              last edited by

                              It's just missing exec bits
                              chmod a+x ufslabels.sh; ./ufslabels.sh

                              Or:
                              sh ufslabels.sh

                              I pushed a fix to correct the exec bits, it'll turn up in shapshots eventually

                              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                              Need help fast? Netgate Global Support!

                              Do not Chat/PM for help!

                              1 Reply Last reply Reply Quote 0
                              • AhnHELA
                                AhnHEL
                                last edited by

                                Does that printout look normal with the unexpected operator?  End result seems to be correct.

                                
                                [2.1-RC0][root@pfsense@pfsenseuser.net]/root(17): chmod a+x /usr/local/sbin/ufslabels.sh ; /usr/local/sbin/ufslabels.sh
                                FS: / on device ada0s1a with ufsid 51f5bc9c854a3254
                                FS: Swap on device ada0s1b
                                ====================
                                Current fstab:
                                # Device                Mountpoint      FStype  Options         Dump    Pass#
                                /dev/ada0s1a            /               ufs     rw              1       1
                                /dev/ada0s1b            none            swap    sw              0       0
                                ====================
                                New fstab:
                                # Device                Mountpoint      FStype  Options         Dump    Pass#
                                /dev/ufsid/51f5bc9c854a3254             /               ufs     rw             11
                                /dev/label/swap         none            swap    sw              0       0
                                [: =: unexpected operator
                                Commit changes? (y/n):
                                y
                                Disabling swap to apply label
                                Applying label to swap parition
                                Activating new fstab
                                Re-enabling swap[/code]
                                

                                AhnHEL (Angel)

                                1 Reply Last reply Reply Quote 0
                                • jimpJ
                                  jimp Rebel Alliance Developer Netgate
                                  last edited by

                                  That's not fatal (it was in code to auto-commit the changes if you passed in the right command line parameter), but it isn't relevant to using it interactively, so you can proceed from there.

                                  Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                  Need help fast? Netgate Global Support!

                                  Do not Chat/PM for help!

                                  1 Reply Last reply Reply Quote 0
                                  • w0wW
                                    w0w
                                    last edited by

                                    Looks like SMART is also fixed
                                    https://redmine.pfsense.org/projects/pfsense/repository/revisions/ccf479876283082b39ac9a37c1c6308f4857a6f0/diff

                                    Thanks jimp!

                                    1 Reply Last reply Reply Quote 0
                                    • T
                                      Tikimotel
                                      last edited by

                                      For completeness the smart dashboard widget needs the same fix.

                                      1 Reply Last reply Reply Quote 0
                                      • w0wW
                                        w0w
                                        last edited by

                                        @Tikimotel:

                                        For completeness the smart dashboard widget needs the same fix.

                                        Exactly.

                                        1 Reply Last reply Reply Quote 0
                                        • jimpJ
                                          jimp Rebel Alliance Developer Netgate
                                          last edited by

                                          I just forgot about the widget entirely in the previous commit.

                                          Done now though:
                                          https://github.com/pfsense/pfsense/commit/0aa297594cd1882f32d52074ba3546c4f5f97c8e

                                          Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                          Need help fast? Netgate Global Support!

                                          Do not Chat/PM for help!

                                          1 Reply Last reply Reply Quote 0
                                          • G
                                            gogol
                                            last edited by

                                            Thanks to your guides I think I have enabled TRIM on my SSD:

                                            /root(5): 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)                                 
                                            
                                            

                                            and from dmesg

                                            ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
                                            ada0: <ts16gssd25s-s v1210=""> ATA-8 SATA 2.x device
                                            ada0: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 512bytes)
                                            ada0: Command Queueing enabled
                                            ada0: 15272MB (31277056 512 byte sectors: 16H 63S/T 16383C)
                                            lapic1: Forcing LINT1 to edge trigger
                                            SMP: AP CPU #1 Launched!
                                            Trying to mount root from ufs:/dev/ufsid/51fa1b22d7786f5c
                                            WARNING: /: TRIM flag on fs but disk does not support TRIM</ts16gssd25s-s>
                                            

                                            Why is there still that last line that my disk doesn't support it?

                                            I have this one:
                                            === START OF INFORMATION SECTION ===
                                            Model Family:    JMicron based SSDs
                                            Device Model:    TS16GSSD25S-S
                                            Serial Number:    00246293003C
                                            Firmware Version: V1210

                                            According to data sheet it does support trim command.

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