TRIM Support comes to Windows Azure Virtual Machines

Monday, October 14 2013

The Windows Azure Virtual Machines (WAVM) feature uses the BLOB storage service to store the actual VHDs for the guest virtual machines.  The OS disk and any attached data disks are basically giant Page Blob files stored in your Windows Azure storage account. 

When the WAVM feature was first announced someone immediately asked the question, “If I have an 100 GB data Disk VHD file in my storage account, but it’s only got 20 GB of space used am I charged for all 100 GB?”  This was a good question and the answer was a “No, but…”.  Only fixed sized VHDs are supported in Windows Azure; however, the storage system supports sparse files, so if only 20 GB of space was used on the VHD then you were only charged for that 20 GB. 

That’s great, but note that if you then added another 30 GB of data and promptly deleted say 40 GB you would be charged 50 GB of storage.  This is because the VHDs worked like any other hard drive and even though you delete the data the actual pages aren’t really removed (which is why things like undelete work and why we have tools like Kill Disk to completely erase disks on our local hard drives). 

The great news is that a change has been released so that Windows Azure VMs for some Windows OSs now support TRIM-like functionality!  A TRIM command to a Solid State Drive is a way for the OS to tell the drive that blocks of data are no longer valid and can be removed.  This type of functionality is now built in to some of the Windows Servers available in Windows Azure.  Basically the OS tells the Storage system that certain pages are no longer valid and they are removed (just like in the SSD TRIM commands).  Note that this works for deleted files, not files that simply changed in size.  The best thing is that this just happens for you behind the scenes and since it is dealt with at the Host level you are likely already enjoying the benefit of this feature.

The Windows Server 2012 and 2012 R2 virtual machines completely support the TRIM like command for all disks (OS and Data).  The Windows Server 2008 R2 based virtual machines only has this support for the OS disk (which is due to the older OS supporting TRIM only on SATA disks and not SCSI which the data disks appear to the OS as).  They are looking at ways of incorporating the same functionality for the Linux based OSs available on Windows Azure, but there are apparently commands that can be used to force this type of operation on Linux manually (I’m not a Linux expert so I won’t be expanding on that).

This is actually a really great feature.  There’s nothing like doing nothing special and saving money while doing it.