DO NOT ENABLE BOTH PERIODIC TRIM AND CONTINOUS TRIM AT THE SAME TIME
ALSO DEBIAN, REDHAT AND OTHERS HIGHLY RECOMMEND TO DITCH CONTINUOS TRIM TO KEEP YOUR SSD HEALTHY AND THERE'S NO GOOD REASON TO HAVE IT RUNNING ON YOUR SYSTEM.
Most SSDs support the ATA_TRIM command for sustained long-term performance and wear-leveling.
As of Linux kernel version 3.8 onwards, support for TRIM was continually added for the different filesystems.
File System | Continous TRIM | Periodic TRIM |
---|---|---|
Btrfs | Yes | Yes |
Ext3 | No | ??? |
Ext4 | Yes | Yes |
F2FS | Yes | Yes |
JFS | Yes | Yes |
NILFS2 | Yes | Yes |
NTFS-3G | No | Yes |
VFAT | Yes | Yes |
XFS | Yes | Yes |
Just in case verify TRIM support with the following command
$ lsblk --discard
In order to do so, you need to also check that you are not currently using Continuos TRIM.
To do so, check your fstab
file.
For Example
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
#
UUID=YOURUUIDFROMYOURDRIVEHERE swap swap defaults 0 0
UUID=YOURUUIDFROMYOURDRIVEHERE / ext4 defaults,noatime,discard 0 1
UUID=YOURUUIDFROMYOURDRIVEHERE /boot ext4 defaults,noatime,discard 0 0
/dev/mapper/home /home ext4 defaults 0 0
Notice the discard
flag after each affected partition/drive. That means you are currently using Continuos TRIM. to disable it, just delete the discard
flag and save your fstab
file.
To turn Periodic TRIM on, just enable the fstrim.timer
service which in turn will run the fstrim.service
once a week.
Just run the follow command:
$ systemctl enable fstrim.timer
To check if it is enabled, run:
$ systemctl status fstrim.timer | grep enabled
And later on to check it is properly running, check the logs to review the last time TRIM run:
$ journalctl -u fstrim
For more information related to TRIM you should check the wiki.
Source:
-
The Arch wiki
-
some reddit post on the archlinux subreddit