• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
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.
  • C
    charliem
    last edited by Jun 21, 2013, 1:15 PM

    Hi Folks – I installed a snapshot (14-June) on a system with a new 64G SanDisk SSD.  AHCI is enabled in the bios, and I turned on TRIM after install, as described here: http://redmine.pfsense.org/issues/2319

    But dmesg shows trim is not enabled:

    [Trying to mount root from ufs:/dev/ad4s1a
    WARNING: /: TRIM flag on fs but disk does not support TRIM[/code]
    
    Seems that the ahci driver is needed for trim to work, but not being used: ahci disks would show up  as ada4, while the above shows ad4 so the older ATA driver is being used.
    
    I will try [code]ahci_load="YES"[/code] in /boot/loader.conf, but I doubt it will work as I don't see any ahci kernel modules to load.
    
    Even if I could enable ahci *after* install, another problem would be the device name changing from ad4 to ada4 (for example), and the boot failing.
    
    Any idea how I can force ahci to be used during a re-install?  Is ahci built into the default kernel config?
    
    Thanks
    
    1 Reply Last reply Reply Quote 0
    • W
      w0w
      last edited by Jun 21, 2013, 6:17 PM Jun 21, 2013, 6:11 PM

      I have this message also and I have different SSD.
      But if you check this page http://doc.pfsense.org/index.php/Boot_Troubleshooting you will find that AHCI is recommended mode for the pfsense and for my pfsense AHCI is enabled in BIOS. I am not sure about how freebsd can work using ATA driver in AHCI mode, but my ssd is ad4, also.

      Device name changing interrupts the boot, but you can manually type the path to boot and then change it in fstab.
      For example the current boot path is /dev/ad4s1a  
      and the new one should be /dev/ada4s1a

      1 Reply Last reply Reply Quote 0
      • T
        Tikimotel
        last edited by Jun 22, 2013, 11:46 AM Jun 22, 2013, 11:42 AM

        I've installed trim on all my partitions, including the separate "/var" partition with softupdates I had chosen from first install.

        Here is in short what I did to get it to work:

        • Download the iso of freebsd 8.3 copy the "ahci.ko" into /boot/kernel/

        • chmod "ahci.ko" to r-xr-xr-x (0555)

        • Check if loads in the console, "kldload ahci" & "kldstat"

        • edit loader.conf to add ahci_load="YES"

        • reboot.

        • at the loader prompt "mountroot" type "?" for list of options.

        • at the loader prompt "mountroot" type "ufs:/dev/ada0s1a" (ada0;ada1;ada4 will depend on chipset used)

        • now that / root is mounted, /bin/sh for a shell

        • vi /etc/fstab

        • change and save the all mountpoints accordingly, including swap. (ada0;ada1;ada4 will depend on chipset used)

        • reboot.

        • pfsense will now boot like before if you have edited fstab correctly.

        • perform the TRIM_set action. http://redmine.pfsense.org/issues/2319

        • I noticed that only "/" is set to support TRIM, check with "tunefs -p /"

        • reboot.

        • choose option 5 (single user mode)

        • type: "tunefs -t enable /dev/ada0s1d" to enable TRIM on the other partion "/var"

        • reboot.

        • check support TRIM, check with "tunefs -p /" & "tunefs -  p /var"

        My AHCI controler is AMD based, so my partitions became "ada0s1a" for / & "ada0s1d" for /var

        $ 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)
        
        $ tunefs -p /var
        tunefs: POSIX.1e ACLs: (-a)                                disabled
        tunefs: NFSv4 ACLs: (-N)                                   disabled
        tunefs: MAC multilabel: (-l)                               disabled
        tunefs: soft updates: (-n)                                 enabled
        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)
        

        partial dmesg:

        $ dmesg |grep ada0
        ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
        ada0: <m4-ct064m4ssd2 040h=""> ATA-9 SATA 3.x device
        ada0: 600.000MB/s transfers (SATA 3.x, UDMA5, PIO 8192bytes)
        ada0: Command Queueing enabled
        ada0: 61057MB (125045424 512 byte sectors: 16H 63S/T 16383C)</m4-ct064m4ssd2>
        
        1 Reply Last reply Reply Quote 0
        • W
          w0w
          last edited by Jun 22, 2013, 4:15 PM Jun 22, 2013, 4:10 PM

          This did the trick! Thanks Tikimotel .
          Only one thing that I did not - tunefs trim enable for var partition, as it was already enabled.
          And my mistake was thinking that ad4 became ada4, wrong! :) it's ada0 now

          1 Reply Last reply Reply Quote 0
          • T
            Tikimotel
            last edited by Jun 22, 2013, 5:22 PM

            Just be careful when updating the builds.
            Updating deletes the "ahci.ko" from the /boot/kernel folder.
            So you'll have to do the opposite with mountroot, to mount the "/" partition (mount the non ahci name again), boot for a bit and copy "ahci.ko back again and reboot and finish/or re-install the packages.

            1 Reply Last reply Reply Quote 0
            • W
              w0w
              last edited by Jun 22, 2013, 7:16 PM Jun 22, 2013, 7:15 PM

              This would be good to include ahci.ko to the next builds. I hope jimp read this.
              So we don't really need the option to enable trim during install for the 2.1, that is RC already, but at least it could be documented in some new ssd section of pfsense docs later and user can change the default driver if needed. I think including ahci.ko into boot kernel would not cause to drop rc stage back to alpha or beta ;)

              1 Reply Last reply Reply Quote 0
              • P
                ptt Rebel Alliance
                last edited by Jun 23, 2013, 3:51 PM

                Have you tried the "ahci.ko" in the "/boot/modules/" instead the "/boot/kernel/" ? To avoid it to be deleted, when update….

                1 Reply Last reply Reply Quote 0
                • W
                  w0w
                  last edited by Jun 23, 2013, 4:22 PM Jun 23, 2013, 4:12 PM

                  Trying right now…

                  Yes, it works! Thanks for the hint, ptt!

                  1 Reply Last reply Reply Quote 0
                  • C
                    charliem
                    last edited by Jun 23, 2013, 6:41 PM

                    Thanks guys!  I will do this later tonight.

                    I second the idea of including ahci.ko in the pfSense build.  It would be great to have a way to enable TRIM with pfSense 2.1 without having to download FreeBSD 8.3 release, and worry about breaking your system with an update.  Would be pretty innocuous as a module in the /boot/modules directory, and there would be no worries about compatibility of modules from different compiler versions.

                    Even booting FreeBSD 8.3 or 8.4 live fixit mode, my SSD is detected as ata by default, not ahci.  So including it as a module should be very safe.

                    Thanks ….... Charlie

                    1 Reply Last reply Reply Quote 0
                    • T
                      Tikimotel
                      last edited by Jun 23, 2013, 6:42 PM

                      @ptt:

                      Have you tried the "ahci.ko" in the "/boot/modules/" instead the "/boot/kernel/" ? To avoid it to be deleted, when update….

                      Awesome that did it!

                      1 Reply Last reply Reply Quote 0
                      • AhnHELA
                        AhnHEL
                        last edited by Jun 25, 2013, 3:11 AM Jun 23, 2013, 10:37 PM

                        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 Jun 23, 2013, 10:40 PM

                          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
                          • P
                            ptt Rebel Alliance
                            last edited by Jun 23, 2013, 11:41 PM Jun 23, 2013, 11:39 PM

                            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
                            • W
                              w0w
                              last edited by Jun 24, 2013, 5:25 AM

                              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
                              • W
                                w0w
                                last edited by Jun 27, 2013, 6:24 PM

                                
                                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 Jun 28, 2013, 2:31 AM

                                  @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
                                  • W
                                    w0w
                                    last edited by Jun 28, 2013, 5:29 PM Jun 28, 2013, 1:50 PM

                                    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 Jul 16, 2013, 11:05 AM

                                      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 Jul 16, 2013, 11:14 AM

                                        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 Jul 16, 2013, 12:36 PM

                                          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
                                          • First post
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.