Managing Hyper-V virtual disks
In one of my previous articles, I went over all the ins and outs of managing networking on Hyper-V servers. However, there’s a whole lot more to virtual environments than networking. One absolutely critical resource is disk storage and understanding how to manage disk storage in Hyper-V is important to overall project success. In this article, I’ll discuss the basic concepts behind storage management in Hyper-V.
For the purposes of this article, I’m running Hyper-V on two servers:
- A physical Windows Server 2008 R2 server running on a Dell PowerEdge 2950 server.
- A virtual Windows Server 2008 R2 SP1 server. The server is running as a guest inside a virtual machine.
Hyper-V storage support
Let’s start at the beginning. Hyper-V supports a lot of different kinds of storage including both directly attached storage and storage area networks. For each of these overarching storage paradigms, the following technologies are supported:
Direct Attach Storage (DAS)
- FireWire/IEEE 1394 devices
Storage Area Networks (SANs)
- Fiber Channel
Network Attached Storage (NAS) Is not supported for Hyper-V virtual disks.
Default VHD file location
By default, VHD files are stored at C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks. If you’d like to change this location so that VHD files aren’t accidentally created here, from the Hyper-V Manager, right-click your Hyper-V server and, from the shortcut menu, choose Hyper-V Settings.
Figure 1: Go to Hyper-V Settings
The first option on the Hyper-V Settings page provides you with a place to change the location of your virtual hard disks. Click the Browse button if you’d like to find an alternative location.
Figure 2: Default VHD file location
Hyper-V disk types
There are four primary disks types you can create in Hyper-V.
A fixed VHD volume is created up front and has all of its space allocated at the time the volume is created. So, if you create a new disk volume and give it a size of 127 GB, that new volume will immediately consume 127 GB of disk space on the host. There used to be a day when fixed virtual disk files were much better performers than their dynamic counterparts. Those days are largely gone. Although users might enjoy a slight performance benefit from using fixed virtual disks over dynamic ones, the difference is not huge.
- By using fixed disks, you can better estimate overall host storage usage and not have to worry about accidentally overprovisioning storage resources.
- Virtual disk files are portable and easily copied from machine to machine.
- For virtual disks, these are the fastest, although the performance margins continue to close as Microsoft makes improvements in Hyper-V and VHD handling.
- You waste a whole lot of storage if you make volumes too large.
- You can’t shrink a fixed disk to make use of the “unused” space.
Like a fixed disk, you specify the size of a dynamic disk at the time its created but the amount of space on the host actually used by the disk depends on how much data is being stored on that particular volume. This concept is also known as thin provisioning.
For example, if you create a 127 GB dynamic disk but the virtual machine is using only 20 GB of space on that disk, which will also be the amount of disk space consumed by the volume. Whenever reasonable, I highly recommend that you use dynamic disks as your storage medium of choice.
- You can stretch your expensive storage resources much further and still provide virtual machines with space allocations that make sense. This provides a lower total cost for the service.
- Virtual disk files are portable and easily copied from machine to machine.
- You can accidentally overprovision storage on the host and create infrastructure stability issues as a result.
- Requires an additional level of oversight so that storage resources aren’t overprovisioned.
- There is a slight performance hit as space is allocated for usage.
- If you expand a volume, write operations may suffer during the expansion operations, but this is temporary.
At Westminster College, although we used VMware, this thin provisioning concept follows and we use it for every single virtual machine we run as a way to reduce overall storage costs. We do carefully watch storage and migrate virtual machines to new stores as necessary, but it has helped us reduce the overall amount of storage we need for our virtual environment.
Sometimes, a service needs direct access to physical disks and won’t support the use of a VHD. Or, the service simply needs so much disk space that presenting a physical volume makes more sense. For example, while I was creating my Data Protection Manager 2010 course for Train Signal, I needed to use a storage volume that was huge in size and based on physical – not virtual – disks.
A pass-through disk allows you to mount a physical volume to a Hyper-V virtual machine. In my DPM course, I used a pass-through disk to act as the storage pool device that I needed to use for my lab scenarios. There are, however, some serious drawbacks to the use of pass-through disks.
- Allows you access to volumes exceeding 2 TB in size from within the Hyper-V virtual machine.
- Carries a performance gain over virtual disks since there is no abstraction taking place. The virtual machine has direct access to the disk.
- Not portable at all. It’s tougher to move the storage to another server.
- You cannot take snapshots of a pass-through disk.
- The Hyper-V VSS writer cannot back up a pass-through disk. If you’re backup software uses this common protection technique, you’ll need to find alternative methods – such as installing a backup agent inside the virtual machine itself – for protecting the contents of the pass-through disk.
A differencing disk is a dynamically expanding disk that is chained to a parent disk. With a differencing disk, the parent disk never changes; all changed blocks are reflected in the differencing disk. With this method, you can create a bunch of identical virtual machines and each can have its own differencing disk for customizations, but the parent disk is never changed.
Microsoft recommends that you always use fixed size virtual disks in a production environment in order to eliminate the possibility of running out of storage space as disks expand. While I see the point of their guidance, I disagree with it if you have the ability to carefully monitor your storage usage. If you do, dynamically expanding virtual disks provide you with a lower overall cost of ownership as well as additional flexibility with regard to shared disk storage.
Although VHD files do provide some significant flexibility, such as enabling the ability to create snapshots and move virtual machines from host to host, they do carry some limitations:
- Change from Windows Server 2008 to Windows Server 2008 R2. You can no longer mount a VHD from within a compressed folder. This capability was removed from R2 in order to prevent potential VHD corruption.
- You can only mount VHD files that reside on NTFS volumes. If you’re using differencing disks, all of the VHD files in the chain must be on NTFS volumes. For most organizations, this shouldn’t be much of a limitation.
- The maximum size of a VHD file is 2040 GB, just shy of 2 TB.
- If you intend to use a VHD file as a boot file for a Windows 7 desktop, make sure you understand that only the Windows 7 Enterprise and Ultimate edition support booting from VHD.
Editing a virtual disk
Information Technology environments are hardly static entities; indeed, they change often and they change significantly. The disks associated with your individual Hyper-V-based virtual machines are no exception. As time goes on, you may find it necessary to modify the properties for one of these disks. To get started, from the Hyper-V Manager, choose the Edit Disk option from the Tasks area. You can see this option highlighted in the figure below.
Figure 3: Select Edit Disk to get started
Once the Hyper-V Manager has been informed that you want to edit a disk, you’re asked to indicate which disk it is you’d like to manipulate. In Figure 4 below, provide the full path to the VHD file you’d like to work with. Click the Browse button to browse the file search in search of the target VHD (Figure 5).
Figure 4: Which VHD file do you want to modify?
Locate the desired VHD file
Once you’ve identified the target VHD file, there are a number of actions at your disposal, although not every action is available in every scenario. In Figure 6, you’ll notice that there are three actions available –Compact, Convert and Expand. For some VHD files, there are also two additional options – Merge and Reconnect.
- Compact. This option applies to dynamicand differencing virtual hard disks. Compacting a virtual hard disk reduces the size of the .vhd file by removing blank space that is left behind when data is deleted from the virtual hard disk.
- Convert. If you’ve created a dynamic disk, you can convert it to a fixed disk with this option. Alternatively, if you’ve created a fixed disk, you can convert it to a dynamically expanding virtual hard disk with this option.
- Expand. No one is perfect. You migt have accidentally created a virtual volume that is a little too small. Using the expand option, you can increase the storage capacity of a dynamic or fixed virtual hard disk.
- Merge. This option applies to differencing disks only. The merge option provides you with the ability to combine the contents of a differencing disk with the contents of the parent disk. With this option, you can either:
o Create a new, third virtual hard disk that is the combination of the original parent disk and the differencing disk.
o Apply the changes directly to the parent disk. This might be useful in VDI scenarios when you apply updates.
- Reconnect. This option applies to differencing disks only. This option becomes available if the parent of a differencing virtual disk cannot be located. It provides you with a way to reconnect a this child disk with its parent.
Figure 6: The options associated with this virtual hard disk
In this article, we discussed some of the important management options surrounding VHD files as well as covered some of the options associated with VHD file creation.