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
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.
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
- 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.
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:
(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:
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:
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:
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.