Does SSD TRIM work with a 'Boot from VHD' scenario?

9

3

I have recently purchased an Intel X-25 G2 SSD (160GB) as an extra drive for my laptop.

I created a fixed size disk virtual disk (40GB) and have installed Windows Server 2008 R2 onto this VHD. I now 'boot to VHD'.

(I want multiple development environments, therefore separate VHD's are the way to go for me.)

This works great and fast. No complaints.

Just a nagging feeling. How does TRIM work in this scenario? Am I potentially trashing my SSD by using it like this?

I couldn't find any definitive answers via Google.. I ran "fsutil behavior query disabledeletenotify" and it returned '0'. However this is apparently not definitive.

I ran the defragmentation program, and it seems the SSD drive is available for this task.

Is there:

1) Any way I can determine TRIM is working? 2) If not, how do I enable?

user46462

Posted 2010-10-02T12:18:09.760

Reputation:

Since I asked this question almost 3 years ago, I thought I'd add a postscript. Basically my SSD is still going strong after 2 years of fairly solid VHD usage. – None – 2013-08-22T00:44:14.537

Answers

3

A work-in-progress document on Microsoft site notes new features of 8 platform. They do not specify wether this only works on server or client:

http://msdn.microsoft.com/en-us/library/hh848053%28v=vs.85%29.aspx

They also say a little about the new VHDX format, which is supposed to support TRIM,

http://technet.microsoft.com/en-us/library/hh831446.aspx

I can't verify this is working because right now I have a w8cp running on the standard vhd format so I'll try to perform a clean reinstall on the new vhdx format. If you're unpatient, you can do this yourself and watch a file deletion with procmon (you're supposed to see a number of certain api calls, see below details)

"We're sorry, but as a spam prevention mechanism, new users can only post a maximum of two hyperlinks": ocztechnologyforum.com/forum/showthread.php?66696-New-FW-Flashing

user80758

Posted 2010-10-02T12:18:09.760

Reputation:

2

To my knowledge no virtualisation solutions yet support telling the OS in the VM that it is in fact on an SSD (the virtual drive and controller will look the same to the guest OS wether is it on a spinning-metal based disk, an SSD or even an entirely RAM based drive) and translating TRIM commands from the guest OS to correct TRIM commands relative to the host drive.

You will have better luck in this regard using variable sized virtual disks (as when they are shrunk the space deallocated from the file will be released by the filesystem code and it will request appropriate TRIM commands are issued) but using growable virtual disks has a performance hit of its own so you'd have to do some research to see if this hits you use more than the lack of TRIM support for the space used by the fixed-size vdisk (my gut says that the fixed sized disk is the way to go, but I would do some performance tests to verify this).

David Spillett

Posted 2010-10-02T12:18:09.760

Reputation: 22 424

1

A virtual machine has virtual hardware and doesn't know anything about the actual hard disk. It also doesn't need to know that, as the host operating system takes care of everything. While fine in theory, this does break down for SSD.

The VHD file is always used in its entirety in the eyes of the host with no free spaces. Therefore the host will never apply TRIM to the VHD. There is no technology that lets the guest and host communicate, since that would be a serious security breach.

So the answer is positive: You are thrashing your SSD.

Consider:

  1. Putting the VHD on non-SSD disk,
  2. Deleting the VHD sooner or later from the SSD disk (TRIM will then be applied),
  3. Using variable-sized VHD (I doubt this will even postpone the problem, being equally wasteful as regarding TRIM),
  4. Partitioning the SSD into two partitions and use disk-imaging software to swap virtual machines into/out of the second partition (this might require the ingenuous use of a wiper product - maybe using the operating system to delete and recreate the second partition would do the trick).

harrymc

Posted 2010-10-02T12:18:09.760

Reputation: 306 093

2Thanks for your detailed answer. Just to be clear, I am not running a virtual machine but actually booting my physical machine from a VHD file. In this scenario, I believe that ONLY the disk management is virtualized. This likely means that your advice still holds true, but could you confirm? – None – 2010-10-04T01:45:29.687

1

Windows 8 added support for SSD TRIM commands in its VHDX format, making very easy to boot from a virtual drive on an SSD drive.

http://www.jaylee.org/post/2012/07/13/Windows-8-Developers-Hyper-V-and-the-new-VHDX-format.aspx

Tarnay Kálmán

Posted 2010-10-02T12:18:09.760

Reputation: 3 457