Part of the reason why virtual machines are so great is because virtual hard disks (VHDs) are so flexible. Compared with their physical counterparts, VHDs can be created in, added to and removed from a virtual machine (VM) quickly and easily. VHDs also support various configurations that can allow you to use physical disk space efficiently. In this article, we will look at the various types of VHDs supported by Microsoft Virtual Server and how you can use each one.
Virtual hard disks have two main types: fixed-size and dynamically expanding hard disks. Both types have a maximum size value that specifies how large the disk will appear to virtual machines that are hosted within Virtual Server. However, fixed-size VHDs will automatically take up physical disk space on the host computer's file system, whereas dynamically expanding disks will allocate space only as needed. Overall, the dynamic option is easier to manage (especially if you are limited by available physical disk space), but the fixed-size option can offer the best performance (by avoiding overhead and fragmentation related to growing the files).
Linked hard disks map to a single physical hard disk on the host computer. This type of hard disk is created primarily for converting a physical hard disk into a VHD. First, you create the linked VHD, and then you convert it to a fixed-size or dynamically expanding VHD. Beware that if you make a linked hard disk accessible to a virtual machine, the VM can
Figure 1: Comparing the different virtual hard disk types
One advantage of working with virtual machines is the ability to roll back a VM to its previous state. In Virtual Server, you can accomplish this by enabling Undo disks. When you check this box, Virtual Server will automatically create a .vud file for each of the VHDs that are attached to the VM. This will effectively make the .vhd files read-only, and all write operations will be performed to the undo files. When you choose to power off a VM, you can keep the undo disks, commit the changes (which updates the base VHD files) or discard the changes (which effectively rolls a VM back to its state before undo disks were enabled).
Differencing disks are based on either a fixed-size or dynamically expanding VHD. These disks store all of the changes that would otherwise be written to the parent VHD. Differencing disks can be configured with parent-child relationships that can form a hierarchy of VHD types (see Figure 2). The most important point to keep in mind is that any VHD that serves as a parent must remain read-only. Differencing disks can increase manageability (especially when multiple VMs share a similar configuration) and can dramatically reduce the amount of disk space required on a Virtual Server host computer. The drawbacks are that differencing disks can be difficult to manage and large hierarchies of disks can potentially lead to performance problems (especially if all of the physical VHD files are located on the same disks or arrays). Within Virtual Server, you can merge a differencing disk with its parent -- an operation that commits all the changes and either updates the base VHD or creates a new VHD file.
Figure 2: Creating a hierarchy using differencing disks
While the concept of differencing disks is similar to that of undo disks, there are some important differences. First, differencing disks are based on single VHDs whereas undo disks are enabled for an entire VM. Second, differencing disks can be used to create hierarchies of virtual hard disks, whereas undo disks are always based on a single base hard disk. Finally, when powering off a virtual machine that uses differencing disks, you are not given the option of keeping or discarding the differencing disks - merge operations must be performed manually. You can use both differencing disks and undo disks on a single virtual machine, but it is important to develop a useful naming convention to avoid confusion.
Last, it is important to keep in mind that VHDs can be moved and copied between virtual machines (assuming the VMs are powered off). In addition, you can convert between different virtual hard disk types. Overall, the flexibility of Virtual Server's virtual hard disk architecture can help you manage your VMs while making efficient use of disk space.
This was first published in June 2006