Skip to content

Instantly share code, notes, and snippets.

@mdouchement
Last active February 13, 2024 08:19
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mdouchement/853fbd4185743689f58c to your computer and use it in GitHub Desktop.
Save mdouchement/853fbd4185743689f58c to your computer and use it in GitHub Desktop.
Enable TRIM on pfsense 2.2.4

Installation

Use memstick-licecd to install pfsense on your SSD.

Enable TRIM

  • Initialize fstab:
[2.2.4-RELEASE][root@pfSense.localdomain]/root: /usr/local/sbin/ufslabels.sh

It may do nothing because all is already initialize but it's only in a case of

  • Enable AHCI by adding ahci_load="YES" in th following file:
[2.2.4-RELEASE][root@pfSense.localdomain]/root: vi /boot/loader.conf.local
  • Get your device ID by showing the fstab file:
[2.2.4-RELEASE][root@pfSense.localdomain]/root: cat /etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ufsid/563dee910aa6a80a             /               ufs     rw              1       1
/dev/label/swap0                none            swap    sw              0       0

Check the Device ID that is mounted on /, in this example it's /dev/ufsid/563dee910aa6a80a

  • Before enabling TRIM, the partition/device must be unmounted so you have to reboot pfsense in Single User mode.
[2.2.4-RELEASE][root@pfSense.localdomain]/root: reboot
  • Add your USB memstick-livecd and boot on it and select 2 then use tunefs to enable TRIM:
          __ ____
   _ __  / _/ ___|  ___ _ __  ___  ___
  | '_ \| |_\___ \ / _ \ '_ \/ __|/ _ \
  | |_) |  _|___) |  __/ | | \__ \  __/
  | .__/|_| |____/ \___|_| |_|___/\___|
  |_|


 +------------Welcome to pfSense-----------+
 |                                         |                 ______
 |  1. Boot Multi User [Enter]             |                /      \
 |  2. Boot [S]ingle User                  |          _____/    f   \
 |  3. [Esc]ape to loader prompt           |         /     \        /
 |  4. Reboot                              |        /   p   \______/  Sense
 |                                         |        \       /      \
 |  Options:                               |         \_____/        \
 |  5. [K]ernel: kernel (1 of 2)           |               \        /
 |  6. Configure Boot [O]ptions...         |                \______/
 |                                         |
 |                                         |
 |                                         |
 +-----------------------------------------+


...


Enter full pathname of shell or RETURN for /bin/sh:
# /sbin/tunefs -t enable /dev/ufsid/563dee910aa6a80a
tunefs: issue TRIM to the disk set
# /sbin/reboot
  • Boot pfsense in normal mode then go in shell and you can check that TRIM is now activated:
[2.2.4-RELEASE][root@pfSense.localdomain]/root: tunefs -p /
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       enabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         enabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
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: space to hold for metadata blocks: (-k)            6408
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)
[2.2.4-RELEASE][root@pfSense.localdomain]/root: 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: soft update journaling: (-j)                       enabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         enabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
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: space to hold for metadata blocks: (-k)            6408
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)

Links that help me to write this tutorial

@aviator4life
Copy link

aviator4life commented Sep 27, 2016

Thanks for sharing this! Also works on 2.3.2-RELEASE (amd64) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment