Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Although TRIM support was introduced to make SSD work better, it should also help virtual machines optimizing virtual disks (for example to know which parts of virtual disks needs no storage on physical partitions). Does any VM machine use TRIM this way?

share|improve this question

Virtualbox and vSphere supports TRIM for the guest. Windows 8 also supports TRIM for the new VHDX image format

VMware Workstation 10 supports SSD passthrough too.

share|improve this answer
It's quite possible that this is what I was looking for. Thanks. – liori Sep 18 '13 at 10:36

TRIM support requires intimate knowledge of the underlying hardware. Since Virtual machines (VM Guests) by definition run on virtual hardware, they are not aware of the details of the hard drive or SSD on which they reside.

So, if the VM Host operating system understands TRIM, that should be sufficient for all VM Guests running on top of it.

Some VM Hosts can "pass through" a physical drive and mount it directly to the operating system on a VM Guest. Depending on the exact implementation, it is theoretically possible that the Guest could then support the TRIM feature of an SSD. As with most things, your mileage may vary, and if it's critical for your environment you should test it thoroughly before you commit.

share|improve this answer
The only thing I would add is if the vm hard drive file is dynamic, you could shrink it and the host would then, if appropriate, tell the SSD to trim the newly freed sectors. This may speed vm hard drive file writes because when the file grows your not modifying existing host sectors, new/trimmed sectors could be used for the guest's write. Normally I fix size on my vm hard drive files, but that is to prevent fragmentation on HDs. With SSDs I would probably go dynamic and periodic shrink. – Scott McClenning Oct 1 '10 at 5:32

TRIM was invented because writes to an SSD must be done in 512K blocks and detmining how much of a block is actually used by a file or files is impossible for the SSD drive itself and must be communicated by the OS and the filesystem.



The wiki link says it better than I could:

The TRIM command does not work with disks which are stored in disk image files. This is caused by the fact that computer files can only be deleted completely or truncated at the end. This problem affects applications like virtual disk services, virtual machines, etc.

share|improve this answer
VM could keep information about which blocks were trimmed to be used when user request to repack and shrink virtual disks. VMWare currently has a similar operation, but it works by overwriting all free space inside VM firstly. – liori Sep 29 '10 at 9:05
The question is not about translating a TRIM operation on the virtual disk to a TRIM operation on the host disk. As you point out, it does not work so directly. The question is clearly about translating a TRIM call on the virtual disk to a shortening of the image file on the host disk (which, incidentally, can in turn trigger a TRIM operation on the host disk, but the question is about the first step) – Pascal Cuoq Feb 3 '15 at 10:41
There are spares files, which should be ideal to be used as a trim-able disk image for a vm. – not-a-user Nov 27 '15 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .