Partilhar via


Rapid Provisioning in VMM 2008 R2 using the UseLocalVirtualHardDisks and SkipInstallVirtualizationGuestServices flags

At MMS 2009, our team announced a new feature of VMM 2008 R2 called Rapid Provisioning. This feature is not available in VMM 2008 R2 beta, but it will be available in the upcoming release candidate and in the RTM version.

This feature was implemented in response to customers requests. In VMM 2008, the only way to deploy a new virtual machine is to copy the VHD from the library to the host over the network using BITS. Depending on the size of VHD and the available bandwidth, this could take several minutes or even hours. We heard from a lot of customers that they have sophisticated SAN technologies that enables them to clone a LUN which contains the VHD and present it to the host. However, customers still want to leverage VMM’s template capabilities with OS customization and IC installation. So they basically wanted new-VM without the network copy which is exactly what we did with Rapid Provisioning. You can now create a template which includes the OS answer file and which references a "dummy" blank VHD which is not going to used. Then, using Windows PowerShell (There is no GUI support for Rapid Provisioning since we expect customers to use this feature in massive deployments that are automated) you can execute the New-VM cmdlet and specify the local path to the VHD using a new switch –UseLocalVirtualHardDisk.

Here is a sample script where a new virtual machine is created by utilizing the local VHD d:\file.vhd without copying any VHDs over the network.

<<

#specify the file location
$VHDName = "d:\file.vhd"

#specify other variables for new-vm
$vmname = "vm1"
$hostname = "host.contoso.com"
$vmhost = get-vmhost $hostname

#create jobgroup ID for new-vm from template
$VMGuid = [System.Guid]::NewGuid().ToString()

#specify the local location for the VHD

#VMM expects that $VHDName already exists on the host computer when the new-vm cmdlet is called.
Move-VirtualHardDisk -Bus 0 -LUN 0 -IDE -Path $VHDName -JobGroup $VMGuid

#get the template name
$template = Get-Template | where {$_.Name -eq "template_2"}

#Get the current username to be passed as the VM owner
$callerUsername = whoami

#create the new-vm from template and specify the Rapid Provisioning flag (-uselocalvirtualharddisks)
New-VM -Template $template -Name $vmname -Description "" -Owner $callerUsername  -VMHost $vmhost -UseLocalVirtualHardDisks -Path $vmhost.VMPaths[0] -RunAsynchronously -JobGroup $VMGuid | Out-Null
 >>

 

Notice that using a similar methodology we could create a differencing disk from a VHD file on the host computer. Then, we could use this differencing disk as the target disk for the new virtual machine creation. This allows you to copy a single base disk with your OS on a host, and then use the Rapid Provisioning feature to create multiple Virtual Machines using differencing disks off that same base VHD. I have attached a PSM1 Windows PowerShell module that helps you do all of this and encapsulates them inside a new cmdlet. This module can be imported in your PowerShell console and exposes a new cmdlet called New-DiffVM. You can use this cmdlet to take advantage of rapid provisioning and do differencing disk standup of VMs. To use this module, see the cmdlets to execute below. The last cmdlet will create a new differeencing disk called child.vhd from the base disk base.vhd and create a new VM and attach it to child.vhd. This script and the entire Rapid Provisioning feature expects child.vhd to already exist on the host computer when new-vm is called. In addition, we expect the user that is executing this new cmdlet to be an administrator on the host computer so that it can create the differencing disk for the VM.

<<

PS > import-module .\NewDiffDiskVMModule.psm1

PS > get-help New-DiffVM -detailed

New-DiffVM [-ParentVHDPath] <String> [-NewChildVHDPath] <String> [-HostComputerName] <String> [-VirtualMachineName] <String> [-TemplateName] <String> [-VirtualMachineServerName] <String> [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]

PS > New-DiffVM -ParentVHDPath "d:\base.vhd" -NewChildVHDPath "d:\child.vhd" -HostComputerName "host.contoso.com" -VirtualMachineName "diffvm1" -TemplateName "template_2" -VirtualMachineServerName "vmmserver.contoso.com"

>>

 

In addition to the new UseLocalVirtualHardDisks, VMM 2008 R2 has added one more new flag called SkipInstallVirtualizationGuestServices. This flag allows you to skip the installation of the Integration Components (ICs) as part of New-VM if you are already certain that your template either contains the ICs or it contains an operating system that has built-in integration components. The New-VM cmdlet from the above example can be modified as below for this scenario. This will create a new VM using the local VHD filepath specified and will skill the IC installation. Furthermore, if your template has specified no OS customizations (meaning no sysprep or unattend actions will be executed), then New-VM can be completed in seconds!!!!

<<

#create the new-vm from template and specify the Rapid Provisioning flags (-uselocalvirtualharddisks and -SkipInstallVirtualizationGuestServices)
New-VM -Template $template -Name $vmname -Description "" -Owner $callerUsername  -VMHost $vmhost -UseLocalVirtualHardDisks -SkipInstallVirtualizationGuestServices -Path $vmhost.VMPaths[0] -RunAsynchronously -JobGroup $VMGuid | Out-Null

>>

 

These new features of VMM 2008 R2 will allow customers to rapidly create VIrtual Machines while leveraging their existing investments in SAN hardware. Keep the feedback coming folks :)

NewDiffDiskVMModule.psm1

Comments

  • Anonymous
    January 01, 2003
    PingBack from http://up2v.wordpress.com/2009/05/08/scvmm-2008-r2-offers-rapid-provisioning/

  • Anonymous
    January 01, 2003
    Ровно месяц назад появился кандидат для выпуска (Release candidate) Windows Server 2008 R2 — и мы сразу же начали получать вопросы о том, когда же выйдет соответствующий ему выпуск System Center Virtual Machine Manager 2008 R2. Надо сказать, что стандартный