In this post I will look Inspecting and Editing virtual disks in Hyper-V. In a previous post I looked at creating a vm template to deploy virtual machines from. The template used a Dynamically expanding virtual hard disk, so although the virtual machines’s operating system would see it as 127GB it’s actual size at deployment was 18GB, and it will grow as required up to its specified maximum size.
This is great for keeping storage usage down while testing or for templates storage, but in a production envrionment it is best practice to deploy fixed disks to increase disk throughput.
From within Hyper-V Manager you can select Inspect Disk whether the virtual machine in question is turned on or off.
Select Inspect Disk from the Actions menu, browse to the disk you want to inspect, in this example I will look at Phoenix’s virtual hard disk.
As you can see the Phoenix is currently using a Dyanmically expanding virtual hard disk with a maximum size of 127GB, and currently is 17.63GB in size.
Now before we deploy Phoenix into production I want to change the disk type from Dynamically expanding to Fixed. To do this you have to shut the virtual machine down. If you edit the disk while it is running you only have the Compact or Expand options available to you (See below).
In Hyper-V Manager with Phoenix shutdown select Edit Disk. (You can also perform the following steps from within the settings of the virtual machine, which saves a couple of clicks as the virtual hard disk in question is already selected in the Edit disk wizard).
Click Browse, and locate the virtual hard disk file, then click Next.
Now that the virtual hard disk file is not in use you have a new option to Convert it. Select the Convert radio button, this gives you three more steps in the Wizard. Click Next.
Choose the Disk Format, in this example I’m working in a pure 2012 R2 environment so I will select the VHDX radio button, and click Next.
Select the Fixed size radio button, because this virtual machine is going to go into production, click Next.
Choose a name and location for the fixed disk, the wizard will convert the selected disk to a new file, so I have choosen to save it to the D:Temp folder and called it the same name as the original disk. Click Next.
Converting this disk took approximately three minutes on a server with out of hours iops, obviously the time it will take will depend on your storage infrastructure.
Browse to D:Hyper-VVirtual Hard Disks and rename the original Phoenix.vhdx file to Phoenix-original-dynamic.vhdx. Now browse to D:Temp and copy the new fixed disk Phoenix.vhdx to D:Hyper-VVirtual Hard Disks. The image below shows the original and the new disk highlighted, notice the difference in size.
Now although we have renamed the new Fixed disk to be the same as the original Dynamic disk, we need to go into the VM Settings and remove the original disk and add the new disk so it has the correct permissions. If you compare the two disks permissions at this stage you will notice they are different.
Right click Phoenix, select Settings, highlight the Hard Drive, and click Remove, then click Apply.
Now highlight Hard Drive and click Add, click Browse and select Phoenix.vhdx, click Open and finally click Apply then OK.
You can now power on the virtual machine Phoenix with its new fixed disk.