In This Article
What is Virtual Hard Disk (VHD)?
When a virtual file format represents a physical hard drive, it is called a Virtual Hard Disk or VHD. It is typically used to store all the contents of the hard drive of a computer, including the structural and data elements.
Technically, a VHD is a disk image file format with .vhd file extension, which replicates the present hard drive, and is also called the Virtual Machine, sometimes. It is portable and can be kept anywhere reachable by the physical host.
- The Virtual Hard Disks format usually refers to the hard drive but it exists as a file, and therefore, is transportable. Normally used with the Virtual Machines, these can also be used with the physical machines.
- Since the virtual disk is transportable, it can be stored anywhere that the physical host can access it. Its transportability feature also allows moving and storing it on a USB flash memory device.
- Usually, the functionalities of the VHDs are very much the same as the functionalities of the typical physical hard drives. However, these disks are installed, accessed and managed on a Virtual Machine (VM) structure.
- The VHDs allow loading several operating systems on the same host system to offer a performance boost, and at the same time, they allow the developers to perform more cost-efficient software testing.
- The VMs typically rely on the VHDs pretty much as a physical system depends on the physical hard disk drive fitted in a computer. So, it is vital to know and master the creation and configuration methods of these disks.
Understanding Virtual Hard Disk (VHD)
A Virtual Hard Disk is a file format or an application that is specially designed to be used primarily by a Virtual Machine (VM).
Its architecture is pretty much the same as the current physical hard drive of the computer system, including the sectors typically found on it, which include much more than the following:
- A file system
- The disk partitions
You can store it anywhere you like, but you must make sure that it is easily accessible to the physical host. For example:
- You can store the VHD on a Universal Serial Bus (USB) flash memory device and move it as and when necessary.
- You can also store the virtual disk, or its configuration, to be more precise, on a partition that is BitLocker encrypted.
Ideally, storing the VHD in a BitLocker encrypted partition is much better an option because of two specific reasons, such as:
- It will provide the data stored on the disk with an additional layer of security, irrespective of the guest operating system.
- You can also extend the BitLocker protection to legacy and incompatible Windows operating systems.
Usually, the Virtual Hard Disks function much like the traditional physical hard disk drives. This is because they have all the capabilities to perform the same functions, which includes but are not limited to the following:
- Creating disk sectors
- Creating files and folders
- Running an operating system
- Installing and executing other applications
Though a VHD is formed on a physical hard drive, it comes with its own logical distribution.
As a result, these disks can, in turn, host several different virtual hard drives at the same time, though it will primarily depend on their size.
These multiple virtual disks will, however, not interfere with or overwrite the functions of the other VHDs because each of these disks is built as a firmly united drive.
The sizes of these VHDs can be either fixed or flexible, but both will be controlled and managed by either one of the following:
- The parent operating system of the computer
- The virtualization manager
Created by Connectix for the Connectix Virtual PC software, a Virtual Hard Disk comes with some noteworthy characteristics and features. These features allow doing a lot of different things, such as:
- It allows loading several operating systems onto the same host system.
- It allows the developers to perform software testing in a more cost-efficient way.
The software was purchased by Microsoft later, on February 19, 2003. They named the product Microsoft Virtual PC to use in the VM applications for the Windows operating systems.
The VHD on a Windows computer appears just like the physical disks when you check it in the Disk Management utility.
The VHD icon will be blue when it is attached and gray when detached, irrespective of the operating system used on the computer, which may be any of the following:
Virtual Hard Disk Types
Ideally, there are three main types of Virtual Hard Disk formats available for use namely, fixed VHD, dynamic VHD, and differencing VHD.
Each of these has different features and capabilities, as explained hereunder:
Fixed Virtual Hard Disk
In this specific VHD format, the disk typically uses a fixed amount of space, just as the name indicates, of the hard disk drive of the host machine.
This specific type of virtual disk has the ability to support much faster data processing speeds and continuous fragmentation.
Dynamic Virtual Hard Disk
In this specific VHD format, once again, just as the name suggests, the disk size is variable.
Typically, the amount of storage space used by this type of disk starts with a bare minimum size, but it gradually grows as and when more and more data is stored on the virtual disk.
The most significant benefit offered by the Dynamic VHD is that it allows much faster allocation of the storage space.
Differencing Virtual Hard Disk
This type of virtual disk is especially useful when it is needed to create a copy of the current hard disk. In this specific format, there are two separate Virtual Hard Disks used.
One of these is called the parent disk, while the other is referred to as its child. The most significant benefit offered by the differencing VHD setup is that it allows making changes to a parent virtual disk without needing to change that disk.
What is a Virtual Hard Disk Used for?
A Virtual Hard Disk is typically used to store all of the contents of a physical hard disk drive in a computer system.
There are also lots of other good reasons to use a Virtual Hard Disk. Some of them are as follows:
- These virtual disks allow easy deployment because they typically come with provisions for standard and pre-built configurations in the files. This allows these disks to work with specific operating system settings, further simplifying deployment.
- It is quite easy to recover data, if it is deleted accidentally from the VHD or even affected by a malicious software or virus injection, due to its efficient backup and restore feature.
- It even allows recovering a snapshot of the current VHD configuration, thereby allowing the users to return to a former stage if there are any issues with the installation and general troubleshooting does not fix the issue.
- The VHD will allow safe and swift replication of the file or job done in one system to another system, which is a very useful feature of the VHD for the developers who often collaborate on a project.
- It is also used by the specific users who prefer to work in isolation and on their favored operating system without interfering to or interference from the other users.
- It is also used for more cost-effective returns because these virtual disks eliminate the need for multiple operating systems and hardware components. This, in turn, reduces the cost of deployment and storage as well.
How to Open a Virtual Hard Disk File?
In order to open a Virtual Hard Disk file on your Windows computer, you will first have to create it, attach it and then open it. It is not at all difficult when you use the Disk Management utility.
It will help you to mount the VHD file, copy and even add the files and folders to an image when you need a single folder or a file system image or a VHD file created by Windows backup.
The steps to follow for each of these processes are different and are explained separately in brief for your better understanding.
Creating and opening a VHD
In order to create a Virtual Hard Disk on a computer running on Windows, these are the steps to follow:
- Get Admin access
- Right-click on the Disk Management
- Go to the Action menu
- Let the Create and Attach Virtual Hard Disk dialog box appear
- Type the path to the VHD file you want to mount (if you do not know it, click on Browse to find it on your computer)
- Select Create VHD
- Press Open
- Specify the location for storing the VHD on the physical computer
- Go to the Virtual Hard Disk format window
- Leave the Read-Only box unchecked
- Mention the size of the VHD, either fixed or dynamically expanding size
- Click OK
- Open File explorer to check the new addition
Attaching a VHD
In order to make the new VHD partition available for use, you will need to attach it first. The steps to follow for it are:
- Right-click on the Disk Management
- Let the Attach Virtual Hard Disk window appear
- Go to the Action menu
- Select Attach VHD
- Specify the VHD location you want to use
- Mention whether you want it to be mounted as Read-Only or otherwise
- Click OK
In order to attach the VHD, here are the steps to follow:
- Open the Task Scheduler
- Go to the Action panel
- Click on Create Task on it
- Click on the General tab on it
- Type the name of the VHD that you want to attach
- Select the ‘Run whether user is logged on or not’ box
- Check the Run with Highest Privileges box
- Choose Windows 10 from the Configure for dropdown list
- Go to the Triggers tab
- Click on New
- Go to Begin the Task List at the top in the New Trigger window
- Select At startup on it
- Click on OK
- Go to the Actions tab
- Click New
- Type powershell.exe in the Program/Script field in the New Action window
- Go to the Add arguments (optional) text field
- Type the command: Mount-DiskImage “Path to the VHD file”
- Change the “Path to the VHD file” with the actual path to the VHD file that you want to attach
- Press OK
- Once more press OK to save this task of mounting a VHD
- Enter the user account information by typing the user name in the right field
- Type in the password
- Press OK
When the VHD is attached to your computer system, it will appear in the Disk Management. However, if it is new, you will have to initialize it to bring it online and open it to use it.
Are Virtual Hard Disk Files Safe?
Well, whether or not the Virtual Hard Disks are safe depends largely on your use.
Usually these files are safe, but they can be dangerous due to several reasons such as combining of the kernel-level file system parsing, allowing the files to arrive at the endpoint or lack of Mark Of The Web (MOTW) tagging to the content that may prevent finding the source of a file from the internet.
There are also a few other instances when the VHD files may prove to be dangerous for a computer system. These are:
- If there is a specially crafted file system in the VHD, clicking on it may crash Windows or even cause worse damage than that.
- If the contents of the VHD files are not properly scanned by web and email gateway security products, the existence of malware will not be detected within the files.
It is up to you to make using the VHD files safe. Some of the proven strategies to ensure that and minimize the risk of system crash are as follows:
- Blocking VHD files at email gateways
- Unregistering the VHD file extensions in Microsoft Windows Explorer
Where are the Virtual Hard Disk Files Stored?
If it is a standalone host, by default, the Virtual Hard Disk files are stored in two different locations in Drive C: for the configuration files and the hard disk files.
Typically, the two locations where you will find the new VHD files are as follows:
- Configuration files: C:\ProgramData\Microsoft\Windows\Hyper-V
- VHD files: C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks.
Can a Virtual Hard Disk File be Deleted?
If you do not need to use a Virtual Hard Disk file anymore, you can delete it to free up some storage space in your computer system. You can do it from two different options namely, via Command Prompt or via Disk Management Console.
Detaching a VHD
When you are done working with the VHD, you may want to unmount the mounted virtual image. The simple steps to follow for it are:
- Go to Computer Management
- Select Disk Management
- Right-click on the disk you want to delete
- Select Detach VHD
- Click OK to finish
You may note at this point that detaching the VHD will not delete it completely. It will simply remove it from the Disk Management window, and you will not see it when you open File Explorer, thereby making it unavailable for use.
To delete it completely using Command Prompt, the following steps are to be followed:
- Type cmd to go to the Command Prompt application
- Right-click on it
- Select Run as administrator option
- Click on Yes to continue
- Run diskpart on the Command Prompt screen
- Select the VHD file running the command select vdisk file= “<enter VHD file path location>”
- Use the command detach vdisk to delete the VHD file from the disk location
- Exit the Command Prompt window.
While using the Disk Management Console, follow these steps:
- Go to Start
- Select the My PC icon
- Right-click on it
- Select Manage option
- Go to Storage on the Computer Management page
- Select the Disk Management option
(You can alternatively press the Windows key and R key simultaneously to open the Run box and then type diskmgmt.msc and hit Enter)
- Select the VHD you want to delete
- Right-click on it
- Click on the Delete Volume option
- Click on Yes on the notification for confirmation that comes up
- Right-click on the VHD disk icon
- Select Detach VHD even if the status of the disk is changed from Online to Unallocated
This will delete the VHD file from the Disk Management system completely.
Virtual Hard Disk Vs Physical Hard Disk
- A Virtual Hard Disk is designed to be used by the Virtual Machines while the physical hard disk drives are meant to be used by the physical computer systems.
- The Virtual Hard Disks are installed in the virtual machine infrastructure. On the other hand, the physical hard disk drives are installed on the physical machines.
- The VHDs are virtualized and are created on the physical hard drive itself, but they come with their own logical distribution.
What is the Size Limit for Virtual Hard Disks?
Ideally, there can be fixed and variable sizes, but the Virtual Hard Disk format, which is supported with all Hyper-V versions, comes with a maximum size limit of 2 terabytes (TB), or 2040 GB to be more precise.
Ideally, the Virtual Hard Disks format is very much similar to the hard drive but it is basically in a disk image file format with a .vhd file extension.
This means that it is very much portable and can be used in both a Virtual Machine as well as a physical machine.
There are different types of VHDs and are quite easy to use.