Virtual Hard Disk (VHD) Architecture explained

Virtual Hard Disk (VHD) Architecture explained

  • Comments 15
  • Likes

A virtual hard disk (VHD) is a file that encapsulates a hard disk image. VHDs can be used in new and interesting ways. VHDs first were created to be the storage media for virtual machines (VMs). Today, VHDs are used to ship trial versions of software, used in backup solutions, used for bug triage (e.g. customers can convert a physical disk to virtual and share it), and even used to store multiple boot environments. VHDs are a very flexible storage container and are not tied to any single file system format. Since June 2005, Microsoft has made the VHD Image Format Specification available to third parties under the Microsoft Open Specification Promise (OSP).

Microsoft began using VHD technology in Microsoft Virtual PC around 2003, and then continued its use in Microsoft Virtual Server release in 2005. The next major release happened as part of Hyper-V in Windows Server 2008. Currently VHD support is made as part of Windows Server 2008 R2 and high-end client SKUs of Windows 7. VHDs were limited to use by virtual machines running in Virtual PC/Virtual Server/Hyper-V and loopback mounting of VHDs in the parent partition sometimes referred to as the management operating system. The integration of VHD support into the operating system was drastically improved in Windows Server 2008 R2 which added native support. Native support means the technology is integrated into the operating system and no longer requires a virtualization solution such as Hyper-V to be available. Native support added the following features:

  1. Boot from VHD
  2. Integrated support for attaching and detaching VHDs via inbox APIs (virtdisk.dll) and the “Disk Management” control panel (diskmgmt.msc or command line tool DiskPart (“attaching” is the term used to describe the action of mounting a VHD so it can be used by Windows directly, or as a disk in the guest operating system of a virtual machine).
  3. Attaching VHDs from inside VHDs, and many performance improvements.

There are three VHD formats each with different performance characteristics. The three formats of VHD are fixed, dynamic and differencing.

image

A fixed sized VHD uses a file in which the space to store the file is allocated on the physical storage when the virtual hard disk is created. The file size is the same as the size specified for the virtual hard disk. As their name implies, fixed sized VHDs occupy the same space on the underlying physical storage device as their specified size. However, once a fixed sized VHD is created, the size can be increased when the disk is offline by editing the disk to expand it. Reducing the size is not supported. Because the physical storage required for a fixed size VHD is allocated when the VHD is created, there is a better chance at optimal placement and organization on-disk which yields the best performance. The disadvantage is the space is committed even if it is not used.

image

A dynamically expanding VHD is a file that at any given time is as large as the actual data written to it plus the size of on-disk meta-data. Dynamically expanding disks are useful because they do not require all the storage needed to contain the maximum size of the disk to be reserved up front. The VHD file starts quite small (e.g. 42KB is a typical physical size of an empty 20GB disk) and grows as new blocks in the disk are used. There are a number of optimizations around dynamically expanding disks that improve performance; however, in general their read/write performance is slower than fixed disks. One optimization is the selection of data block size which can be either 512KB or 2MB; another is skipping allocation of all-zero blocks.

image

A differencing VHD is a file representing the current state of the virtual hard disk as a set of modified blocks in comparison to a parent virtual hard disk. Differencing VHDs can be associated with either a fixed sized or dynamically expanding VHD. Differencing VHDs can also be associated with another differencing VHD but they cannot be associated with a physical disk. Differencing VHDs are used to prevent changes from being made in their parent VHD to which they are applied and are used to implement a number of additional features. In Hyper-V, differencing VHDs are also created automatically whenever snapshots are taken of a virtual machine. Note differencing VHDs used for snapshot purpose are named with an AVHD file extension to help users easily distinguish them from regular differencing VHDs. Differencing VHDs may also be used to deploy a “golden” or “master” image, because you can associate multiple differencing VHDs to one parent VHD. Some disadvantages of differencing VHDs are increased caching needs and the inability to grow or shrink the VHD size. You can however compact differencing VHDs to reclaim physical space usage.

There are several important limitations for VHDs:

  1. VHDs can be mounted only on NTFS volumes (although you can still save a VHD file on FAT/FAT32 assuming the maximum file size limit is not violated). For example, if you have a differencing VHD chain, then every VHD along the chain must sit on an NTFS volume to make VHD attaching work.
  2. VHDs cannot be mounted within a compressed folder in Windows Server 2008 R2. This was possible in Hyper-V role in Windows Server 2008, but this capability was explicitly blocked in the Hyper-V role in Windows Server 2008 R2 since the compressed file size limit is relatively small. A dynamically expandable VHD can easily outgrow that limit and get corrupted.
  3. In addition to the maximum file size of NTFS, dynamic or difference VHDs cannot exceed 2040GB. The reason for the 2040G limit is the length of each Block Allocation Table entry is set to 4 Bytes and the maximum valid value is 0xFFFFFFFE (0xFFFFFFFF means an unused entry). If you multiply that value by 512B sector size and then subtract the overhead of on disk meta-data structures, 2040G will be the maximum size of dynamically or differencing VHDs.

 

 

Comments
  • <p>nice</p>

  • <p>Very nice and simple description of the concept of Virtual Disk</p>

  • <p>informative post . thanks for knowledge sharing &nbsp;:)</p>

  • <p>This is perhaps the most clear and concise description of the VHD format I have seen yet. &nbsp;Thanks.</p>

  • <p>it is really good.</p> <p>we need to have indepth explanation regarding data storage management in virtual environments......</p>

  • <p>I am a newbie.</p> <p>Do VHDs persists upon reboots?</p>

  • <p>Simple but effective description . thanks</p>

  • <p>Hey Ranjana,</p> <p>The information is just sweet and simple and I will share with Hyper-V starters.</p> <p>Keep sharing .</p> <p>Rajesh Parasa</p> <p>praajesh@gmail.com</p>

  • <p>it possible to install xp on vhd and boot from a physical machine ???</p>

  • <p>!!!!!!!!!!!!!!!!!!!Booting from a VHD!!!!!!!!!!!!!!!!!!</p> <p>You can also boot an alternate operating system from VHD, the advantage being that you get the benefits of both dual boot and virtualization together. The VHD operates in a virtual environment that will not impact your primary operating system. Also, because it runs from boot rather than virtualized within the primary operating system, it doesn&#39;t have to share system resources.</p> <p>The ability to boot from VHD provides a number of benefits. It enables organizations to work with and test various operating system environments from a single hardware platform. By reserving a base copy of each operating system VHD, developers can work freely with each environment without concern for the changes being made; the original VHD is still available to provide a clean slate.</p> <p>Testing any operating system configuration changes or new applications should be done in a virtual environment to prevent any impact or adverse effects on the primary or production operating system.</p> <p>On the one hand, the VHD provides more security because any malware compromises or data breaches that might occur will only affect the virtual operating system. It is worth noting, however, that the VHD environment must be updated and protected just like any other operating system if you want to secure it and ensure it does not become infected or compromised.</p> <p>To install Windows 7 to boot from a VHD, follow these steps (again, make sure you back up your system and have sufficient free space on your physical drive first):</p> <p>Boot your computer using the Windows 7 installation DVD.</p> <p>Select Repair Your Computer.</p> <p>Choose your existing primary operating system and click Next.</p> <p>Click on Command Prompt and issue the following commands (change C: to whatever physical drive and path you want to create the VHD on, and set the max size to the number of megabytes you wish):</p> <p>create vdisk file = c: vhd win7.vhd max = 10000</p> <p>select vdisk file = c: vhd win7.vhd</p> <p>attach vdisk</p> <p>exit</p> <p>Type setup.exe and hit Enter.</p> <p>Choose Custom installation.</p> <p>Select the VHD you just created as the destination for installing the operating system.</p> <p>Proceed to install Windows 7 just as you would on any physical drive.</p> <p>Between Windows XP Mode and the ability to work with and boot from VHDs, Windows 7 takes virtualization to a new level and makes it a much more mainstream tool for your computing needs.</p> <p>Virtual computing is generally seen as a drain on system resources, and reserved for uber geeks, but Windows 7 speeds up virtual computing significantly, and booting to a VHD means not having to share system resources at all. Average users can now benefit from the ability to work with multiple operating systems, or create a sandbox operating system for testing purposes using the VHD capabilities in Windows 7.</p>

  • <p>These pretzels are making me thirsty.</p>

  • <p>lol ima mlg u aint got nothin on me</p>

  • <p>People are like bananas, you can peel them open and eat them. </p>

  • <p>I have a simple question. I have Created a 160 GB VHD and the disk.vhd is stored on a seperate partition from main OS. My Question : If i reinstall my OS ( formate my main OS Partition completely) Will i still be able to use the VHD and all files i may have backup?</p> <p>Thanks</p>

  • is it possible on smart phones

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment