{"id":321,"date":"2018-01-08T21:33:13","date_gmt":"2018-01-08T21:33:13","guid":{"rendered":"http:\/\/elmig.debianpt.org\/blog\/?p=321"},"modified":"2025-08-19T00:11:29","modified_gmt":"2025-08-18T23:11:29","slug":"discard-trim-for-ssd-with-etx4-lvm-luks-encrypted-devices-2","status":"publish","type":"post","link":"https:\/\/elmig.debianpt.org\/blog\/?p=321","title":{"rendered":"discard\/TRIM for SSD with etx4, LVM, LUKS encrypted devices"},"content":{"rendered":"<p>Cheatcheat to enable TRIM (discard) in a SSD with ext4, lvm and luks encrypted devices.<\/p>\n<h3>Ext4<\/h3>\n<ul>\n<li>In \/etc\/fstab add discard as option of the ext4 filesystem.<\/li>\n<\/ul>\n<h3>If you are using LVM:<\/h3>\n<ul>\n<li>In \/etc\/lvm\/lvm.conf change issue_discards from 0 to 1.<\/li>\n<\/ul>\n<h3>For Luks crypto:<\/h3>\n<ul>\n<li>Append option discard in \/etc\/crypttab. Line should end like luks,discard.<\/li>\n<li>. Append rd.luks.options=discard to the GRUB_CMDLINE_LINUX_DEFAULT value in \/etc\/default\/grub<\/li>\n<li>And update grub and initramfs by running:<\/li>\n<\/ul>\n<pre>sudo update-grub\r\nsudo update-initramfs -u<\/pre>\n<p>&nbsp;<\/p>\n<h3>Manually TRIM the SSD:<\/h3>\n<p>TRIM (issue discards) on all possible filesystems:<\/p>\n<pre>\u00a0sudo fstrim -av<\/pre>\n<h3>Automatic TRIM on SSD every week:<\/h3>\n<p>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:<\/p>\n<pre> sudo systemctl enable fstrim.timer<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[48,44],"tags":[],"class_list":["post-321","post","type-post","status-publish","format-standard","hentry","category-homelab","category-sysadmin"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=321"}],"version-history":[{"count":1,"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/321\/revisions"}],"predecessor-version":[{"id":322,"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/321\/revisions\/322"}],"wp:attachment":[{"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elmig.debianpt.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}