Enable Trim support on Luks-encrypted device

Hi,

I have been trying to enable Trim support on a Luks-encrypted SSD. I have followed the steps on the Arch Wiki.

Exact steps I performed:

  • Added the discard option for each device to /etc/crypttab
  • Added the rd.luks.options=discard kernel flag to the Grub config (/etc/default/grub)
  • Rebuilt initramfs (sudo dracut -f), regenerated the Grub config (sudo grub-mkconfig -o /boot/grub/grub.cfg) and rebooted

Still, discard/Trim support would not enable. Which I check with sudo dmsetup table | grep discard. I must be missing something, could you please provide your thoughts?

Configs:
Crypttab

luks-a13a1d4a-a6c1-4e2e-ad9e-SNIP UUID=a13a1d4a-a6c1-4e2e-ad9e-SNIP     /crypto_keyfile.bin luks,discard,no-read-workqueue,no-write-workqueue 
luks-23951e0e-26b8-4125-bc3b-SNIP UUID=23951e0e-26b8-4125-bc3b-SNIP     /crypto_keyfile.bin luks,discard,no-read-workqueue,no-write-workqueue

Grub Config

GRUB_CMDLINE_LINUX_DEFAULT='nowatchdog nvme_load=YES rd.luks.uuid=a13a1d4a-a6c1-4e2e-ad9e-SNIP rd.luks.uuid=23951e0e-26b8-4125-bc3b-SNIP rd.luks.options=discard resume=/dev/mapper/luks-23951e0e-26b8-4125-bc3b-SNIP loglevel=3'

DMsetup output

luks-23951e0e-26b8-4125-bc3b-SNIP: 0 18450842 crypt aes-xts-plain64 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 259:3 4096
luks-a13a1d4a-a6c1-4e2e-ad9e-SNIP: 0 979695770 crypt aes-xts-plain64 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 259:2 4096

Did that do the right thing?

Generally you would run sudo dracut-rebuild

2 Likes

Thank you so much! That was the solution. A silly mistake on my end.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.