Deploying Servers - virtual hard disks
Configure Windows Server Hyper-V and virtual machines.
Virtual Hard Disks
Dynamically Expanded and Fixed Virtual Hard Disks
When you create a virtual hard drive, you can define the virtual hard disks as either of two things:
- Fixed-size virtual hard disks: Take up the full amount of disk space when created, even if there is no data using parts of the hard disk. The advantage of a fixed-size virtual hard disk is that if you have to defragment your drive, the large .vhd file will already be continuous, assuming that it was continuous when it was created. However, you have to shut down your virtual machine for a long period of time if you wish to defragment the .vhd files.
- Dynamically expanding hard disks: Expand as they need space, up to their full space. The advantage of a dynamically expanding hard disk is that it uses very little space when it is created. Any sectors that don't have content are not stored in the .vhd file; instead the .vhd file knows those sectors are not being used.
Unfortunately for dynamically expanded hard disks, after sectors are used, even if the files are deleted, the space is still used on the host unless you compress the .vhd files. To compress a .vhd:
- Open the Hyper-V Management console.
- Open the Actions menu and select Edit Disk.
- Select the source .vhd by clicking the Browse button.
- Click the Compact button.
- Click the Finish button.
Differencing Disk A differencing disk is a special type of dynamic disk that stores changes to virtual machine state in a file separate from the base .vhd file. Differencing disks are defined in the context of a parent-child relationship. In this relationship, each child differencing disk has one and only one parent disk, but a parent disk (which remains read-only) may be associated with multiple child differencing disks.
When you create fixed and dynamically expanded hard disks, you specify a size or copy the contents of an available physical disk. For a differencing disk, you specify the location of the disk you want to use as the parent virtual hard disk.
You can use differencing disks to run several similar virtual machines while saving disk space. They can also be used in multiple complex configurations sharing a large common base. You have to build the common base configuration only once, and then create additional virtual machines with incremental changes by using differencing disks that have the base configuration VHD as a parent disk. This way you can have several VMs based on the same base image, but without the disk space overhead. When a virtual machine using differencing disks issues a write operation, the new data is written only to the child differencing disk.
The drawbacks are that differencing disks can be difficult to manage. In addition, 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. After using differencing disks, you can later merge the differencing disks with their parent disk, either by committing all the changes to the base VHD or by creating a new VHD file.