Provisioning Hyper-V VM’s with disks on different CSVs

The Why

Creating a VM with different performance requirements from its disks is a common request, but it is not entirely obvious how to do it from the Microsoft Virtual Machine Manager (VMM). So here is the scenario, you have something like a SQL server you are happy for your OS to sit on slower disks but you want your log drives on flash. When you create the VM using VMM there in no option to create a disk on a CSV separate from the first disk that is created. To workaround this we use PowerShell to first create the new disks and then attach them to the VM.

The How

1 Go ahead and create the VM as normal using the VMM GUI. Specifying the OS to sit on the slower disks of your choosing. You can also add any other disks you are happy to sit on the same CSV as the VM at this stage.

2 To create the disk on a different CSV and in our case a CSV with different performance capabilities we need to use PowerShell. Launch PowerShell from within VMM to ensure you have all the Hyper-V related plugins.

The command is:

New-VHD

The following example creates a thick provisioned 20GB disk.

New-VHD -fixed -path C:\ClusterStorage\CSV1\VM1\disk1.vhdx -SizeBytes 20GB

Note, The path to the cluster is denoted using the standard format C:\ClusterStorage\CSV name.

3 Next you need to attach the VHD to the VM. You can either use either the GUI or run the command

Add-VMHardDiskDrive

You need to run the add disk command from the Hyper-V host that has the VM on it you want to work with, you can check which host the VM sits on from within VMM.

Below is an example that maps the disk found in location C:\ClusterStorage\Volume1\VM1\disk2.vhdx to a virtual machine called VM1.

Add-VMHardDiskDrive -VMName VM1 -path "C:\ClusterStorage\Volume1\VM1\disk2.vhdx"

 

Published by

Leave a Reply

Your email address will not be published. Required fields are marked *