Introduction to Virtual Hard Disk in Windows

Spread the love

Before you start

Objectives: learn what is VHD, why it is used, and which tools are used to manage VHDs.

Prerequisites: no prerequisites.

Key terms: vhd, file, windows, disk, system, create, hard, installation, virtual, boot, drive, size, attach

What is VHD

VHD stands for Virtual Hard Disk. It is a a format that is structured to represent a standard hard disk drive that allows encapsulation of an operating system and data into a single file. That single file supports all standard disk operation. VHD file still resides on our hard drive, but all the content is written inside of VHD. All our partitions, all our data, and the whole file system is saved in a VHD file on our hard drive which we use to boot from. Note that VHD may but doesn’t have to include an operating system and/or data. We can choose the name of our VHD file during the configuration process, but the extension is always .vhd. We can create a new VHD by using the available disk space on our hard drive. Then we can save it to some location on the disk.


353.1 – Regular Installation Compared to VHD

Newly created VHD is similar to an uninitialized hard disk drive. After we create a VHD, we can create one or more partitions in it and format them using FAT, ExFAT or NTFS file system. When it comes to size, VHD can be fixed in size or it can be dynamically expanding. A fixed VHD has a predefined amount of hard disk space, which is reserved on the physical disk. This reservation also includes empty space within the virtual hard disk. This disk type of VHD takes longer to create, but the performance is better because the entire virtual disk is a contiguous block. A dynamically expanding VHD allocates physical disk space as virtual disk storage is used by the virtual machine. That means that the size of the .vhd file grows as we use our virtual machine. Also, dynamically expanding VHD files do not automatically reduce in size when files are deleted. To reduce the size we can use the compact (reduce) action for the VHD. They can also be expanded (increased) to the maximum size available in a VHD.

Existing VHD can be mounted (attached) so that it displays as a disk in our existing operating system. We can assign a drive letter to mounted VHDs. We can only attach a VHD that is located on an NTFS volume, and we cannot attach a VHD that has been compressed by NTFS or encrypted using Encrypting File System (EFS) on the host volume. We can also attach a VHD as read-only disk. That way we can’t modify the contents of VHD. Attached VHDs can be detached (dismounted), and we should do that if we plan to copy it to other location. Detached VHDs can be deleted.

Usage of Virtual Hard Disks

The great thing when using VHD files is that we can configure multiboot or dual-boot systems more easily. When we configure multiboot using regular installations, we would have to create a new partition for our new installation and install Windows there. When using VHD files, we simply create a new VHD file for our new Windows installation. That means that we can have one partition with multiple VHD files (multiple operating systems). If we want to remove an insulation from multiboot environment, it is simple process when using VHDs. We simply delete the VHD file of the operating system that we want to remove, and all should be set.

 Multiboot Environment

353.2 Multiboot Environment

Until now VHD files were used by HyperV, Virtual Server and Virtual PC as virtual disks for running the virtual machines instead of them. The VHD format is also used by Windows server backup, Windows DPM or Data Protection Manager and a lot of other Microsoft and non-Microsoft software. Now we can use a VHD file to host a running operating system without using any other software virtual machine.

When using VHDs we also have more flexibility when it comes to disaster recovery. For example, we can copy the VHD file from one machine that is broken to another computer with similar hardware, and boot up from that VHD. The users will have access to the same installation and data as they did on the old computer.

Management Tools

To manage VHDs we can use DiskPart, Disk Management in Windows,  WIM2VHD and BCDEdit. With Disk Management MMC snap-in we can create, attach and detach VHDs. With DiskPart we can create, attach, detach, compact, expand and view details about VHD. Common diskpart commands used for VHDs are:

  • create vdisk – creates a new VHD, with the size of the VHD file expressed in MB (file name has to have a .vhd extension)
  • attach vdisk – attaches a VHD
  • detach vdisk – detaches a VHD
  • compact vdisk – reduces the size of a VHD
  • expand vdisk – expands the maximum size available in a VHD
  • detail vdisk – displays information about a VHD

The Windows Automated Installation Kit (Windows AIK) has a utility named WIM2VHD which we can use to create a VHD image from Windows installation source. Using WIM2VHD we can create a new VHD of a specified type and size, apply a .wim to a VHD, use an Unattend file to automate the Out Of Box experience portion of Windows setup the first time a generalized VHD is booted, and apply updates to VHDs.

We can also use deployment tools to install a Windows installation directly onto a VHD file. This direct installation onto a VHD file can then be maintained and deployed. Also, if we already have a computer running Windows 7 Enterprise or Ultimate, we can copy the new VHD file with new system to our hard drive, and configure our computer to boot from the new VHD by using the BCDedit command. BCDEdit is a command-line tool used to manage BCD stores. Using BCDEdit we can create and modify BCD stores, and add boot menu parameters.


VHDs will not degrade or reduce the performance of our computer and operating system.


To install Windows 7 to a VHD we can insert the installation media, and select the Repair your computer option. Then we open the command prompt. If our hard disk is not configured yes, we can run DiskPart to partition the drive, assign a drive letter, and format the partition. Then we can use DiskPart again to create and attach a VHD file inside the partition. After that we can install Windows 7 to the drive that is the VHD file.

We can use WIM2VHD file to create a VHD image from any Windows 7 installation source. After completing the install, the VHD will boot directly into the Out Of Box Experience (OOBE) and be ready for user customization. This is similar to regular Windows installation. Additionally, WIM2VHD supports the use of answer files created trough Windows SIM to perform an unattended installation. With answer files we can customize the installation before deploying the VHD. WIM2VHD and booting from VHD is only supported in Windows 7 Ultimate, Enterprise and Windows Server 2008R2 editions. All Windows 7 versions allow us to create and attach virtual disks, but only these editions support boot to VHD.

A VHD that holds an operating system and can boot to that operating system is called a native-boot VHD. This is also know as boot to VHD. File system partitions that the native boot VHD contains are automatically visible.


We have separate articles in which we describe how to work with VHDs:


A Virtual Hard Disk a single file that is structured to represent a standard hard disk drive. VHD uses available disk space on the computer. VHD files have a .vhd file extension. VHD can be fixed or dynamically expanding. VHDs can be attached to existing operating system. We can use Disk Management, DiskPart, WIM2VHD and BCDEdit to manage VHD files. VHD that holds an operating system and can boot to that operating system is called a native boot VHD or boot to VHD.

Author: cicnavi