How to Implement Trim on SSD Drives


Recommended Posts

The number shown from the fstrim operation is the number of available bytes on the SSD.

 

I tested fstrim on my new 250GB Samsung SSD and got the following results:

 

Nov 23 08:45:45 Tower logger: /mnt/cache: 130988105728 bytes were trimmed

 

Can you comment on the difference in the available bytes reported by fstrim and those reported by the system. The WebGUI reports 41.4GB used and 209GB free.

 

root@Tower:~# df -k
Filesystem       1K-blocks    Used      Available  Use% Mounted on
/dev/sdh1        244198552    40393304  202931112  17%  /mnt/cache
root@Tower:~#

Link to comment
-v, --verbose

              Verbose execution.  With this option fstrim will output the

              number of bytes passed from the filesystem down the block

              stack to the device for potential discard.  This number is a

              maximum discard amount from the storage device's perspective,

              because FITRIM ioctl called repeated will keep sending the

              same sectors for discard repeatedly.

 

              fstrim will report the same potential discard bytes each time,

              but only sectors which had been written to between the

              discards would actually be discarded by the storage device.

              Further, the kernel block layer reserves the right to adjust

              the discard ranges to fit raid stripe geometry, non-trim

              capable devices in a LVM setup, etc.  These reductions would

              not be reflected in fstrim_range.len (the --length option).

http://man7.org/linux/man-pages/man8/fstrim.8.html

Link to comment
  • 6 months later...

Tops. Easy installation and configuration.

 

As an intermediate step I have created a new plugin "SSD TRIM", which allows to set a schedule for the TRIM operation.

 

The set up can be found under Settings -> Scheduler -> SSD TRIM Settings

 

See Dynamix plugins for installation.

 

Thanks dlandon for all the research.

Link to comment
  • 4 months later...
  • 4 months later...

Hi guys, just looking for confirmation.

 

I'm running 1tb EVO 850 as my cache/docker/VM drive formatted with BTRFS

I'm running it off of my Dell H200 HBA on recent IT firmware (As this gives me SATA3 connectivity) 

I'm running Dynamix TRIM plugin.

 

I'm getting the following error via email notifications: 

fstrim: /mnt/cache: the discard operation is not supported

Is this because i'm running BTRFS or because it's connected via HBA on IT Firmware?

 

Lastly, should i be running on a daily or weekly schedule?

Is it a big deal if i can't issue the FSTRIM command to my SSD?

 

Link to comment
Hi guys, just looking for confirmation.
 
I'm running 1tb EVO 850 as my cache/docker/VM drive formatted with BTRFS
I'm running it off of my Dell H200 HBA on recent IT firmware (As this gives me SATA3 connectivity) 
I'm running Dynamix TRIM plugin.
 
I'm getting the following error via email notifications: 
fstrim: /mnt/cache: the discard operation is not supported

Is this because i'm running BTRFS or because it's connected via HBA on IT Firmware?
 
Lastly, should i be running on a daily or weekly schedule?
Is it a big deal if i can't issue the FSTRIM command to my SSD?
 



SAS2008 based controllers don't support trim on most SSDs, you should connect the SSD on the onboard controller, swap with another disk if needed.
Link to comment
  • 2 weeks later...
  • 6 months later...

I recently had an external HDD attached and mounted with the path '/mnt/disks/External_Data_1'.

 

Ever since I unmounted and removed said external HDD I get this annoying email everytime the trim runs:
 

Header of the email: "cron for user root /sbin/fstrim -a -v | logger &> /dev/null"

Content of the email: "fstrim: /mnt/disks/External_Data_1: FITRIM ioctl failed: No such file or directory"

 

I have tried deleting and reinstalling the plugin, but this did not solve the issue.

I solved it myself: I removed the drive from "historical devices" on the main pane in unraid. Then I rebooted the whole server and tested. The issue is no more.

Edited by JohanSF
Link to comment
  • 1 year later...

Finally swapped out my cache drive with a Samsung 1tb 860.  Trim was working however i started to have issues with the drive.  It would grind to a halt once it got to 180 GB on it.  I decided to exchange it for a Crucial MX500 1TB.  it seems to be doing much better however when i run the trim command i get fstrim: /mnt/cache: the discard operation is not supported.  Any ideals what's going on?

Link to comment

It is using the same controller the samsung drive was using when it was working..

 

I assume that these two directories are on the cache drive?

sudo fstrim -a -v
/var/lib/docker: 11.9 GiB (12789510144 bytes) trimmed
/etc/libvirt: 921.6 MiB (966324224 bytes) trimmed
 

Edited by dertbv
Link to comment
Just now, dertbv said:

It is using the same controller the samsung drive was using when it was working..

That doesn't mean anything, Samsung supports read zero after trim, Crucial doesn't, so for example the Samsung would work on some LSI controllers, the Crucial won't, but it will work on the onboard SATA ports.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.