Cheatcheat to enable TRIM (discard) in a SSD with ext4, lvm and luks encrypted devices.
Ext4
- In /etc/fstab add discard as option of the ext4 filesystem.
If you are using LVM:
- In /etc/lvm/lvm.conf change issue_discards from 0 to 1.
For Luks crypto:
- Append option discard in /etc/crypttab. Line should end like luks,discard.
- . Append rd.luks.options=discard to the GRUB_CMDLINE_LINUX_DEFAULT value in /etc/default/grub
- And update grub and initramfs by running:
sudo update-grub sudo update-initramfs -u
Manually TRIM the SSD:
TRIM (issue discards) on all possible filesystems:
sudo fstrim -av
Automatic TRIM on SSD every week:
You can also have your system to automatically TRIM every week with the help of a systemd service. To enable the fstrim.timer service just copy /usr/share/doc/util-linux/examples/fstrim.* to /etc/systemd/system and run:
sudo systemctl enable fstrim.timer
Leave a Reply
You must be logged in to post a comment.