Linux – LVM cache and TRIM

cachelinuxlvmssdtrim

I have set up LVM to cache a logical volume (located on an HDD) on a partition of an SSD (in writeback mode if this matters). As far as I can tell, this works correctly and the cache uses all available space.

Now, I am wondering whether this setup issues TRIM command to the SSD and whether issuing such commands is necessary (or reasonable) to extend the SSD's lifetime. I have added discard to the options in /etc/fstab for the cached logical volume's entry. However, I have no idea how this affects the cache partition nor do I have an idea on how to test whether TRIM commands are issued.

Best Answer

To test it, simply use:

fstrim -v -a

This will trim all your SSD block devices (including cached volumes) and print out how much has been trimmed.

Related Question