Page 1 of 1

Crypttab discard option on LVM over LUKS

PostPosted: Jun 28th, '20, 13:06
by Northsoft
Hello, I've set up a LUKS encrypted partition, and a LVM group with home and root partitions there.
Then I've found out that fstrim command says that operation is not supported on encrypted volumes.
I've added a discard option to /etc/crypttab file and called dracut --force command.
Also I've added a discard option for every record of encrypted volumes at /etc/fstab file.
After reboot the fstrim command still says that operation is not supported on encrypted partitions.
The dmsetup command says nothing about discard option.

When I've booted into a live USB OS, I've mounted every partition manually, using cryptsetup --allow-discards and mount -o discard. The fstrim and e2fsck -E discard worked OK.

How should I allow automated TRIM command bypassing if I use LVM over LUKS?

Mageia 8 alpha.

Re: Crypttab discard option on LVM over LUKS

PostPosted: Jun 28th, '20, 17:01
by doktor5000
Do you have issue_discards = 1 in /etc/lvm/lvm.conf ? Also check whether you have rd.luks.options=discard in your initrd, same for all the other options (from crypttab and fstab)
Apart from that, this has been discussed previously in quite some detail in viewtopic.php?f=7&t=9732 and also in https://bugs.mageia.org/show_bug.cgi?id=19086

You may want to read those, and if you get it to work, would be appreciated if you could edit https://wiki.mageia.org/en/Installation_on_a_SSD_(Solid_State_Drive)#The_fstrim_command accordingly with your findings.

Re: Crypttab discard option on LVM over LUKS

PostPosted: Jun 30th, '20, 19:29
by Northsoft
Steps I performed:
— added rd.luks.options=discard to /etc/default/grub;
— called grub2-mkconfig -o /boot/grub2/grub.cfg;
— set issue_discards = 1 to /etc/lvm/lvm.conf;
— checked discard option in /etc/crypttab;
— added rd.luks.allow-discards to /etc/dracut.conf.d/52-northsoft-discard.conf;
— called dracut -f;
— rebooted;
— called fstrim /: «fstrim: /: the discard operation is not supported»