Windows treats a virtual hard disk file as a physical disk. Create one in Disk Management with Action then Create VHD. Choose a fixed size or a dynamically expanding disk and prefer the VHDX format. Attach the file to use the disk and detach it to make the disk unavailable. Every step needs an administrator account.
You want a separate disk for tests or a virtual machine but you have no spare hardware. Virtual hard disks give you that disk as a file.
This guide explains what a VHD is and shows how to create, attach and detach one in Windows.
What is a Virtual Hard Disk?
Microsoft describes VHD as an image format that wraps a hard disk into one file so the operating system can use it as a virtual disk in the same ways as a physical disk. See about VHD.
Its disks can host the NTFS, FAT, exFAT and UDFS file systems. It can also work as a boot disk.
What are the Types of Virtual Hard Disks?
| Type | How It Uses Space | Maximum Size |
|---|---|---|
| Fixed | Allocates the full requested size in advance | Size you request |
| Dynamically expanding | Uses only the space that stored data needs | 2,040 GB for VHD |
| Differencing | Writes changes to a child file and leaves the parent file as it is | 2,040 GB for VHD |
Microsoft states that every virtual disk type has a minimum size of 3 MB. It also warns that creating a dynamic disk does not check free space, so you can request a size larger than the free space on the physical disk.
How do You Create a VHD in Windows?
Microsoft documents the steps in Disk Management. Your account must belong to the Administrators or Backup Operators group. See manage virtual hard disks.
- Search for Disk Management in the Start menu and open it as administrator.
- Open the Action menu and select Create VHD.
- Select Browse and choose a folder. Avoid the Windows directory in the path.
- Enter a file name and select Virtual Disk files (*.vhdx) as the type. Select Save.
- Enter the Virtual hard disk size.
- Select Dynamically expanding or Fixed size and select OK.
Microsoft recommends the VHDX format over VHD. Large fixed size disks take extra time to create. Windows creates and initializes the disk in one step.
How do You Attach a VHD File?
- Open Disk Management as administrator.
- Open the Action menu and select Attach VHD.
- Select Browse and choose the VHDX or VHD file.
- Select OK.
Attached disks show a blue icon and detached disks show a gray icon. Create a volume on a new disk the same way you do for a physical disk.
How do You Detach a VHD?
- Find the virtual disk in the Disk Management list.
- Right click the disk and select Detach VHD.
- Select OK.
Microsoft states that detaching makes the disk unavailable and does not delete the file or its data.
When should You Use a Virtual Hard Disk?
- Testing. Install an app on a separate disk file and delete the file afterward.
- Virtual machines. Hyper-V uses VHD files as boot disks for virtual machines.
- Isolation. Store project files in one portable file.
For physical disk types see the difference between an SSD and an HDD.
Frequently Asked Questions
What is a VHD File?
It is an image of a hard disk. Microsoft describes it as a hard disk wrapped into one file that Windows uses like a physical disk.
Should I Choose VHD or VHDX?
Choose VHDX. Microsoft recommends it over VHD in the Disk Management steps.
What is the Maximum Size of a VHD?
Microsoft states that dynamic and differencing VHD disks reach 2,040 GB at most.
Does Detaching a VHD Delete My Data?
No. Microsoft states that detaching does not delete the file or its data.
Do I Need Administrator Rights?
Yes. Your account must belong to the Administrators or Backup Operators group.
Key Takeaways
- Windows treats a VHD as one file that works like a physical disk.
- Disk Management creates, attaches and detaches virtual disks with the Action menu.
- Fixed disks allocate space in advance and dynamic disks grow with the data.
- Microsoft recommends the VHDX format over VHD.
- Detaching a disk does not delete its data.
Sources and References
This guide follows Microsoft documentation.
- Manage Virtual Hard Disks (Microsoft Learn) learn.microsoft.com
- About VHD (Microsoft Learn) learn.microsoft.com