Lvm – Optimize SSD storage on Centos 6.6 – KVM

kvm-virtualizationlvmssd

I have a Dell R610 with hardware:

  • H700 raid card
  • 4xMicron MX100 512GB -> configured raid 10

I have installed Centos 6.6 on this server and configured:

  • KVM virtualization
  • Volume Group for raid 10 array
  • Each guest VM using Logical Volumes from Volume Group

I have some questions:

  • Do I need to enable dicard (TRIM) both LVM (KVM host) and guest VM file system (vda)? If yes, then how to do this?
  • How can I monitor SSD endurance?
  • How can I optimize the the performance?

Best Answer

TRIM works at the filesystem level so as you're giving your KVM domains a raw block device then you need to enable TRIM from within the domain; your host can't know the domains filesystem utilisation without examining it. To enable this you need to ensure there's a discard='unmap' attribute added to the disk definition in the XML for the domain, this is documented at https://libvirt.org/formatdomain.html#elementsDisks .

Setting issue_discards = 1 in /etc/lvm/lvm.conf means that LVM will issue a TRIM to the underlying PV if any logical volume is reduced or deleted. It's not necessary for normal filesystem TRIM operations.

To initiate the actual TRIM operations, it's generally advised to use the fstrim utility rather than adding the discard mount option. Run this periodically from cron or equivalent. Running it manually will also show you if you've actually got everything set up properly too.

To monitor your SSD's I would assume the S.M.A.R.T. tools should suffice, have a look at the output of smartctl -a /dev/sdX.

Optimising generally involves making sure all of your partitions are aligned properly and the same as with normal disks; minimize your writes where necessary. Adding mount options such as noatime, nodiratime, etc.

Related Topic