Solid-state drive storage works much faster than traditional storage products that use hard drives with rotating disks. This means that VMs that use solid-state drive for back-end storage also run faster. Now that solid-state drive storage has become more affordable, many data centers are implementing it at a large scale. Before starting your large-scale solid-state drive storage implementation, it's useful to consider how the VMs are going to access the storage in order to ensure you get the best possible performance.
Most virtualized environments abstract the hardware from VMs. If this is the case for your setup, dealing with VMs is easy: Make sure you do what's necessary at the hypervisor level, as the VM will pass all work to the hypervisor layer anyway. However, this isn't the case for all virtualized environments.
To increase the speed of VMs, hypervisors like KVM use features that allow the VM to access the hardware directly, such as VirtIO. If you use KVM, you should consider how you want to use trim on the solid-state drive (SSD) media.
The SSD controller can only write to empty blocks on the SSD. When the system needs to overwrite a block, it must be cleared first. This process of clearing blocks, called trimming, occurs when the OS sends a trim command to the SSD driver. Without trim, you would need to store the write operation in cache, where it would have to wait for the blocks to be erased before they could be written again. Most OSes take care of this by running a scheduled utility that trims the entire SSD media, like the fstrim utility for Linux.
Using trim in virtual environments
The basic idea behind virtualization is that operations that optimize hardware use need to be performed close to the hardware. That means the hypervisor host should take care of trim operations in a virtualized environment, and trimming should occur at the storage level in a SAN. This allows you to easily disable the scheduled fstrim utility in the VM.
If, however, your VM uses an optimization mechanism, such as VirtIO, to access the hardware directly, you should make sure to use all SSD optimization options in the VM.
If you're using a Linux VM, there are two options for performing trim operations on the SSD. Many system-based Linux installations have a fstrim.service file that works together with a fstrim.timer file to run trim on a weekly basis, however, they aren't enabled by default. It makes the most sense to use this tool in a KVM environment; when doing so, run the systemctl enable fstrim.timer command to ensure that the trim job will run on a regular basis.
As an alternative, you can also use the discard mount option. This option, which is available for all of the current major file systems, enables trim at a file system level. To use it, include it as a mount option in /etc/fstab for each file system that has its backing storage on SSD.
In many environments, there's no real need to optimize VMs for using back-end solid-state drive storage. If, however, the VM is writing to the hardware in a more direct way, which is the case while using the VirtIO driver in KVM, you should make the VM aware of the underlying storage by running trim operations on a regular basis.
SSD technology best practices
How do longevity features impact SSD storage?
Solid-state drive storage opens up new opportunities