Problem running fstrim on an encrypted partition

Hi all,

I have two partitions (plus Swap) on a Laptop:

T520:/home/docb # more /etc/fstab
/dev/disk/by-id/ata-Samsung_SSD_840_EVO_1TB_S1D9NEADA00473E-part2 swap swap defaults 0 0
/dev/disk/by-id/ata-Samsung_SSD_840_EVO_1TB_S1D9NEADA00473E-part1 / ext4 noatime,acl,user_xattr 1 1
/dev/mapper/cr_ata-Samsung_SSD_840_EVO_1TB_S1D9NEADA00473E-part3 /home ext4 nofail,noatime 0 2

As you can see, it is a Samsung EVO 840 SSD installed. Home partition is encrypted.
Now, when I run fstrim:

T520:/home/docb # fstrim -v /
/: 70,9 GiB (76079407104 bytes) trimmed

Thats fine so far. But:

T520:/home/docb # fstrim -v /home
fstrim: /home: FITRIM ioctl failed: Die Operation wird nicht unterstützt

Translation: This operation is not supported.
Any idea how to solve this?


I had the same problem and had to (re)search for a while to find the (surprisingly simple. and obvious. in retrospect;)) solution here: : by default, neither LVM nor DM-crypt pass any discard (TRIM) commands. The text I linked shows how to change these settings. In short, for the respective filesystem, add the filesystem option discard in /etc/crypttab; and set issue_discards to 1 in /etc/lvm/lvm.conf). Then you have to rebuild initramfs by executing mkinitrd, then you’ll have to reboot - and that’s all. Afterwards, the fstrim command will work again.

Best regards,

Hi Christian,
thanks for the hint!
By chance, the german computer-mag c’t had a similar hint in its issue 22/2014.
After applying the extent to /etc/crypttab, the fstrim command did not issue any error message, but the ‘blocks used’ on the encrypted device (/home) were before and after trim the same, unlike on ‘/’. So it is very likely that it still failed.