I have two SSDs in my system, sdc and sdd.
Sdc1 contains /, sdc5 contains miscellaneous things including a bunch of virtual machines, and sdd5 contains /home and another bunch of virtual machines. Sdd1 is swap, and I don't trim it.
I have installed several files on my system for the SSDs. This includes a service that changes the I/O scheduler for the SSDs to account for their random access nature, a reduction in system swappiness (I do this because I have lots of RAM and don't want to swap unless it is really necessary), and of course the program that does the trim.
I probably only gain 1 or 2 percent in performance by doing these things, but why not?
To handle setting the I/O scheduler and set the swappiness, I have created a service which is located in /etc/systemd/system and named configSSD.service:
- Code: Select all
[Unit]
Description = Configure system for SSD drives
[Service]
ExecStart = /usr/local/bin/configSSD
[Install]
WantedBy = basic.target
This service calls the function /usr/local/bin/configSSD:
- Code: Select all
#!/bin/bash
# configure for SSDs
echo deadline > /sys/block/sdc/queue/scheduler
echo deadline > /sys/block/sdd/queue/scheduler
echo 10 > /proc/sys/vm/swappiness
In /etc/cron/daily, I have placed this script named fstrim (which I did not write; I found it and it works perfectly for me so I use it):
- Code: Select all
#!/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
#
LOG=/var/log/trim.log
echo "*** $(date -R) ***" >> $LOG
for fs in $(lsblk -o MOUNTPOINT,DISC-MAX,FSTYPE | grep -E '^/.* [1-9]+.* ' | awk '{print $1}'); do
fstrim -v "$fs" >> $LOG
done