Ubuntu – How should I configure TRIM Support for LVM logical volumes

12.04kvmlvmssdtrim

I am setting up a notebook for software demo purpose. The machine has a Intel Core i7 CPU, 8GB RAM, a 128GB SSD, and runs Ubuntu 12.04 LTS 64bit desktop. As it is, the SSD is configured to have a single volume group, with /boot, /swap, and / all in their respective logical volume. They collectively consume 30GB space. I plan to use the remaining for logical volumes for KVM guests, all run Ubuntu 12.04 Server

I would like to ensure that the SSD is utilized optimally. Although on this site, there are some great info about setting up TRIM support for file system setups that do not involve LVM, I have not found explicit guide regarding my planned setup.

I did found this page which talks about adding issue_discards in /etc/lvm/lvm.conf. But in said file on my machine, I didn't find the cited content. I double-checked man lvm.conf(5), didn't see any mentioning of this option either.

Thus, I'm not sure what to do. Furthermore, even say adding the option is the right thing to do, should I in my machine's /etc/fstab still add mount options such as noatime etc?

Any tips, pointers, and/or further guidance are greatly appreciated.

Best Answer

For googlers - the issue_discards option is not needed for getting TRIM working when we speak about deleting files. The only effect is has is when you actually modify your LVM (e.g. shrinking or removing logical volumes). But regular users usually do not do this at all.

This setting is recommended for those who are for example provisioning virtual machines on LVM volume groups and delete them often. Otherwise you do not need that. For more info go to lvm.conf man page. This is from RHEL 6.2 LVM Administration Guide:

The Red Hat Enterprise Linux 6.2 release supports the issue_discards parameter in the lvm.conf configuration file. When this parameter is set, LVM will issue discards to a logical volume's underlying physical volumes when the logical volume is no longer using the space on the physical volumes. For information on this parameter, refer to the inline documentation for the /etc/lvm/lvm.conf file, which is also documented in Appendix B, The LVM Configuration Files.

https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/LVM_overview.html

I wrote a blog about this: http://lukas.zapletalovi.com/2013/11/how-to-trim-your-ssd-in-fedora-19.html