10

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.

  • If you do not plan to modify your LVM configuration everyday (and this is expected), you do NOT need to set this at all. See my answer. – lzap Nov 15 '13 at 09:36

3 Answers3

11

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

lzap
  • 718
  • 1
    upvoted - exactly the explanation I needed. Thanks – MountainX Mar 01 '16 at 06:10
  • In your blog you advise to regenerate initrd (dracut -f). But it doesn't appear necessary. If lvremove or lvresize are issued, that would be after normal startup and they should see the configuration with discard enabled regardless of initrd. Or do I miss something? ... maybe not a big deal, just more interested to know how things work – akostadinov Jan 07 '24 at 00:19
  • I don’t remember, to be honest I was told by my colleague who actually work on LVM. No idea, sorry. – lzap Jan 10 '24 at 17:52
3

I backported LVM 2.02.95 to Ubuntu 12.04 and put it in a ppa. To use it, issue the following commands:

sudo apt-add-repository ppa:kalakris/lvm
sudo apt-get update
sudo apt-get install lvm2

After this upgrade, the issue_discards command in /etc/lvm/lvm.conf will be recognized as expected.

kalakris
  • 136
  • Thank you for this! Installed it and nothing broke, which is always a good thing. :-) Is there a way to tell that discards are working? – Rob H Dec 19 '13 at 16:58
2

The option issue_discards is currently not supported on the version of LVM shipped with 12.04.

From the LVM Changelog:

Version 2.02.85 - 29th April 2011

Add new obtain_device_list_from_udev setting to lvm.conf.
Obtain device list from udev by default if LVM2 is compiled with udev support.
Add test for vgimportclone and querying of vgnames with duplicate pvs.
Avoid use of released memory when duplicate PV is found.
Add "devices/issue_discards" to lvm.conf.
...

In 12.04 the LVM version is 2.02.66 (12.10 comes with 2.02.95).

To set this option already now makes no harm, because it is silently ignored.
See Red Hat Bugzilla 820203

gertvdijk
  • 67,947
  • Thanks for the info! Does it mean that with 12.04 LTS, and how I plan setup these KVM guests (each in a separate logical volume), I don't have a way to optimize the usages of the SSD? --Zack – Zack Perry Sep 23 '12 at 04:03
  • 1
    However, these 'discards' will only trigger on remove or reduce operations on LVs. Discards on the filesystem on top of a LV will not propagate! From the same LVM changelog: "Issue discards on lvremove and lvreduce etc. if enabled and supported." – gertvdijk Sep 23 '12 at 13:52
  • Thanks again for chipping in with more info. It seems to me that given what we have collectively seen so far, there is no good way for me to configure my KVM setup to use the computer's SSD with TRIM :-( At this stage, it seems to me that we either forget about LVM, use image based KVM guests, and be able to use TRIM, or use LVM (perhaps nested), and forget about "trimming" the SSD. Oh, well! – Zack Perry Sep 23 '12 at 18:56