Trim on PureOS/Pureboot

I have been struggling to get trim working on my librem 15v4 with pureos/pureboot option. I thought I had it set up but I seem to be missing something. Has anyone enabled trim successfully with this setup? I am wondering if I need to add the ‘allow-discards’ in /etc/crypttab, or somewhere else to get it functioning. I added a grub command line argument in /etc/grub for the luks discard but it doesn’t seem to work, and I do have a weekly fstrim timer running as per the debian forums (and one of the solutions I found on this forum) but it isn’t able to execute the trim and I get the fstrim not supported error. any help would be greatly appreciated!

as far as i know TRIM has to be supported/enabled in the firmware … SSDs usually have this enabled and working under M$ platform but with linux there might be something that needs configuring to work … so far i haven’t had this problem with a ShangSung 970 pro (it’s NVME) … :stuck_out_tongue_winking_eye:

thanks for the response. are you running PureOS with PureBoot ? I have the Samsung NVMe 970 Pro, btw. I was able to enable trim via a weekly cronjob on my MX Linux and Kali machines, but they are not running with encrypted drive via luks. since this is debian buster, I was able to use the fstrim systemd method, but even though it’s enabled, its not actually able to perform the trim and I believe the reason is that it has to be enabled in either crypttab, fstab or both, but I don’t want to mess with them until I have a method that I know will work.

i’m currently on Debian 10 Buster … currently ALSO fiddling around with the graphical installer of Debian testing from the weekly builds but haven’t had much success so far …

You don’t necessarily want to use TRIM with an encrypted file system.

i would go so far as to ONLY TRIM when it’s NEEDED … as it can shorten the lifespan of the SSD if abused … imo a few times a year should be enough …

I agree with you for sure, definitely shouldn’t be abused, and I understand the issues with security, but the concept of trim when used properly will aid in performance overall, but I can’t seem to get it to work yet lol.

things I can’t figure out are difficult for me to let go, which is a gift and a curse, depending on the situation. I have the latest (or close to) samsung nvme pro, and I know ssd’s have come a long way, and even though it has an auto garbage collection feature, the benefits of trim cannot be dismissed. I think I need to edit crypttab, the lvm.conf and then rebuild the Initramfs to get it fully functioning, but I haven’t taken that approach yet.

I don’t think an SSD can really do TRIM without operating system support. Only the operating system knows which blocks on a disk have no relevance to the current contents of the file system.

I am a bit unconvinced that TRIM needs to be done in real-time though. I am happy to let it happen periodically (which a quick examination of my computer says is weekly). NB: Not an encrypted file system so I can’t solve the actual problem.


well just an update, I was able to get it working properly by editing /etc/crypttab, lvm.conf and a grub command line addition, and after reboot, trim is working (not auto, but weekly fstrim) thanks guys

1 Like

pretty please post exactly the steps you took … even if it’s a solution to your own OP … :slight_smile:

1 Like

absolutely bro, here are the steps I took:

in /etc/crypttab, on the line of your luks drive, add discard at the end, for example: luks (ton of digits here) luks,discard
in /etc/lvm/lvm.conf - change issue_discards = 0 to a 1
in /etc/default/grub - find GRUB_CMDLINE_LINUX="", add in “rd.luks.options=discard”
then sudo update-grub
then sudo update-initramfs -u
then reboot
login - test by sudo fstrim -av
after, follow debian wiki to enable weekly fstrim timer, done!

I found this method to work perfectly since we are not adding in discard to /etc/fstab, therefore not enabling auto trim, which is known to be inferior in terms of performance than a weekly fstrim.

hope this helps someone!