Disabling fstrim - under which conditions?

This document (7023805) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 15 and later ServicePacks
SUSE Linux Enterprise Server 12 SP3 and later ServicePacks
SUSE Linux Enterprise Server for SAP Applications 15 and later ServicePacks
SUSE Linux Enterprise Server for SAP Applications 12 SP3 and later ServicePacks
 

Situation

fstrim is used on a mounted filesystem to discard (trim) blocks which are not in use by the filesystem.
This is especially useful for solid-state drives, SSDs and thin-provisioned storage.
 
fstrim is enabled by default and runs weekly, every Monday 00:00:00 (see: 'systemctl list-timers' output).
 
Some admins prefer to disable it, hence the question:
Under which conditions is it okay to disable fstrim, also with reference to SLES SAP HANA.

Resolution

fstrim scans the filesystem and sends 'UNMAP' commands for each unused block it finds.
Consequently fstrim is only needed if:
 
- the underlying device is thin-provisioned
*and*
- the filesystem doesn't use UNMAP internally
 
fstrim (or TRIM/DISCARD in general) only makes a difference to a thin-provisioned system if the system itself is over-provisioned.
If the system has allocated enough space for each LUN (thin-provisioned or not) issuing TRIM commands is not required.
However, running SAP HANA on an over-provisioned storage array is not recommend.
 
Furthermore on SAP HANA systems in DR mode it's strongly advised to NOT use thin provisioned devices.
Thin-provisioning is using an array-wide state and may be ending up in different states on different arrays.
In case of a DR scenario one might be ending up in a situation where one array hits the thin-provisioned limits, whereas the other doesn't. 

Additional Information

1. Disable fstrim:

The fstrim.timer is scheduled to activate the fstrim.service every Monday 00:00:00. fstrim.service then executes '/usr/sbin/fstrim -av'.
 
To stop/disable fstrim:
systemctl stop fstrim.timer
systemctl disable fstrim.timer
(If needed, 'fstrim' can be run manually: "/usr/sbin/fstrim -v <mountpoint>")

Additionally, if needed, fstrim can be disabled by default by running the above commands as a post-install script in an autoyast file. For more information about using post-installation scripts in an autoyast file, see below link:

https://documentation.suse.com/sles/15-SP4/single-html/SLES-autoyast/index.html#post-install-scripts

 
 
2. In case the 'btrfs' filesystem is in use:

Until SLES12 SP5 the BTRFS_TRIM_PERIOD is set to "weekly" in /etc/sysconfig/btrfsmaintenance.
This btrfsmaintenance job, essentially a cron job, can be disabled by setting BTRFS_TRIM_PERIOD="none".

If there's still too much load on the SAN, it might be necessary to set BTRFS_BALANCE_PERIOD to "none" as well.

After changing the parameter run "systemctl restart btrfsmaintenance-refresh.service" to update the cron periods.
 
On SLE15 and later Service Packs, BTRFS_TRIM_PERIOD defaults to "none" and no changes are necessary here.
 
(If needed, btrfs-balance and btrfs-trim can be run manually: "sh /usr/share/btrfsmaintenance/btrfs-balance.sh" and "sh /usr/share/btrfsmaintenance/btrfs-trim.sh")
 
 
3. Validate whether UNMAP is supported on the filesystem
 
To validate whether the filesystem supports UNMAP the discard max value reported by 'lsblk -D' can be looked at.
A discard_max_bytes value of 0 means that the device does not support discard functionality.
The same can be achieved by checking sysfs directly:
 
# cat /sys/block/sda/queue/discard_max_bytes 
0
 
Another method to check if fstrim/UNMAP is or is not supported on a filesystem is to check the 'fstrim -v' output. If fstrim/UNMAP is not supported:
 
'fstrim -v /mnt/xzy' will return
'fstrim: /mnt/xyz: the discard operation is not supported'.
 
If it is supported fstrim will discard unused blocks and report back:
'fstrim -v /mnt/ /mnt: 12.3 Gib (number_of_ bytes) trimmed.
 
 
4. For details about "SCSI Unmap support on IBM Spectrum Virtualize systems (including SAN Volume Controller, Storwize V5000, Storwize V7000, and Flashsystem V9000)" have a look at the IBM Support Documentation at: 

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7023805
  • Creation Date: 02-Apr-2019
  • Modified Date:01-Mar-2023
    • SUSE Linux Enterprise Server
    • SUSE Linux Enterprise Server for SAP Applications

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center