4

I'm installing a system on SSD with LUKS and Btrfs, where should I enable discard option for TRIM support? Only /etc/crypttab, only /etc/fstab, everywhere, or nowhere since Btrfs detects SSDs and enables TRIM support?

I also use LVM, shoud I somehow change configs to activate TRIM support for LVM too?

P.S. I know about security implications on LUKS with TRIM and I'm fine with it.

5

For TRIM to work, it has to be enabled on all layers. The first step therefore is to enable it in LUKS as LUKS normally disables TRIM due to the security implications. For some distributions you do this in the crypttab, for others you need to edit the cmdline. Since LVM is the next layer on top of LUKS it needs to pass TRIM, which it does per default if the underlying device supports it. Additionally you can set issue_discards = 1 in your lvm.conf, which will bulk-TRIM on lvremove and vgremove. With this in place you can either use fstrim or enable btrfs' native discard (set discard in fstab, see here). If everything works successfully, btrfs will print

BTRFS info (device <something>): turning on discard

to syslog.

1
  • If LVM only passes through discards on thick LVs by default, where's the option to disable the passing through of discards? I looked really hard and I can find one. It looks like LVM always passes through discards on thick LVs, and there is no way of disabling it. If so, you shouldn't say "per default". Apr 2 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.