Skip to content

Instantly share code, notes, and snippets.

@jms1989
Forked from mdouchement/trim_pfsense2.2.4.md
Created April 23, 2017 16:40
Show Gist options
  • Save jms1989/e74813ebc47a250b6dbd376fe7fd17b9 to your computer and use it in GitHub Desktop.
Save jms1989/e74813ebc47a250b6dbd376fe7fd17b9 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][[email protected]]/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][[email protected]]/root: vi /boot/loader.conf.local
  • Get your device ID by showing the fstab file:
[2.2.4-RELEASE][[email protected]]/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][[email protected]]/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][[email protected]]/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][[email protected]]/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

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