Skip to content

Instantly share code, notes, and snippets.

@mratsim
Created November 27, 2016 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mratsim/81df761750022bd0b73758c71485da83 to your computer and use it in GitHub Desktop.
Save mratsim/81df761750022bd0b73758c71485da83 to your computer and use it in GitHub Desktop.
Auto trim SSD
#!/bin/sh
#
# To find which FS support trim, we check that DISC-MAX (discard max bytes)
# is great than zero. Check discard_max_bytes documentation at
# https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt
#
for fs in $(lsblk -o MOUNTPOINT,DISC-MAX,FSTYPE | grep -E '^/.* [1-9]+.* ' | awk '{print $1}'); do
fstrim "$fs"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment