How to Create and Use a Virtual Hard Disk
Virtual hard disks (VHDs) are a file type that acts like a hard disk. In previous versions of Windows, VHDs were used by virtual machines, such as those created by Microsoft Virtual Server 2005 or Microsoft Virtual PC. Additionally, Complete PC Backup in Windows Vista created a copy of the computer's hard disk as a VHD disk image.
Beginning with Windows 7, you can now mount VHDs exactly like a physical disk. By mounting a VHD, you can easily copy files to and from the virtual disk. Additionally, Windows 7 can be configured to boot from a VHD.
You can create a VHD from either the Disk Management snap-in or the command line. After you create the VHD, you must attach it and then format it before you can use it, just like a physical partition.
From the Disk Management console, following these steps:
- Right-click Disk Management and then click Create VHD. Follow the prompts that appear.
- Right-click the new disk and then click Initialize Disk. Click OK.
- Right-click the new disk and then click New Simple Volume (or select a different volume type, if available). Follow the prompts that appear.
The new virtual disk is ready to be used, just like any other disk.
From the DiskPart command-line tool at an elevated command prompt, run the create vdisk command and specify the file (to name the file) and maximum (to set the maximum size in megabytes) parameters. The following code demonstrates how to create a VHD file at C:\vdisks\disk1.vdh with a maximum file size of 16 GB (or 16,000 MB).
DiskPart Microsoft DiskPart version 6.1.7100 Copyright (C) 1999-2008 Microsoft Corporation. On computer: WIN7 DISKPART> create vdisk file="C:\vdisks\disk1.vhd" maximum=16000
|Volume 0||F||New Volume||NTFS||Simple||20 GB||Healthy|
|Volume 1||E||New Volume||NTFS||Simple||40 GB||Healthy|
|Volume 2||R||DVD-ROM||0 GB||No Media|
|Volume 3||C||NTFS||Partition||75 GB||Healthy||System|
|Volume 4||D||New Volume||NTFS||Partition||52 GB||Healthy|
DISKPART> select volume 0 Volume 0 is the selected volume. DISKPART> delete volume DiskPart successfully deleted the volume.
For additional options, run the command help create vdisk at the DiskPart command prompt.
After you create a VHD, you must attach it, create a partition, assign it a drive letter, and format it before it can be used. The following script (which must be run within a DiskPart session) demonstrates how to do this.
create vdisk file="C:\vdisks\disk1.vhd" maximum=16000 attach vdisk create partition primary assign letter=g format
In this tutorial:
- Managing Disks and File Systems
- Overview of Partitioning Disks
- How to Choose Between MBR or GPT
- Converting from MBR to GPT Disks
- GPT Partitions
- Choosing Basic or Dynamic Disks
- Working with Volumes
- How to Create a Simple Volume
- How to Create a Spanned Volume
- How to Create a Striped Volume
- How to Resize a Volume
- How to Delete a Volume
- How to Create and Use a Virtual Hard Disk
- File System Fragmentation
- Backup And Restore
- How File Backups Work
- File and Folder Backup Structure
- How System Image Backups Work
- How to Start a System Image Backup from the Command Line
- How to Restore a System Image Backup
- System Image Backup Structure
- Best Practices for Computer Backups
- How to Manage Backup Using Group Policy Settings
- Previous Versions and Shadow Copies
- How to Manage Shadow Copies
- How to Restore a File with Previous Versions
- How to Configure Previous Versions with Group Policy Settings
- Windows ReadyBoost
- BitLocker Drive Encryption
- How BitLocker Encrypts Data
- How BitLocker Protects Data
- TPM with External Key (Require Startup USB Key At Every Startup)
- TPM with PIN (Require PIN At Every Startup)
- TPM with PIN and External Key
- BitLocker To Go
- BitLocker Phases
- Requirements for Protecting the System Volume with BitLocker
- How to Enable the Use of BitLocker on the System Volume on Computers Without TPM
- How to Enable BitLocker Encryption on System Volumes
- How to Enable BitLocker Encryption on Data Volumes
- How to Manage BitLocker Keys on a Local Computer
- How to Manage BitLocker from the Command Line
- How to Recover Data Protected by BitLocker
- How to Disable or Remove BitLocker Drive Encryption
- How to Decommission a BitLocker Drive Permanently
- How to Prepare AD DS for BitLocker
- How to Configure a Data Recovery Agent
- How to Manage BitLocker with Group Policy
- The Costs of BitLocker
- Windows 7 Encrypting File System
- How to Export Personal Certificates
- How to Import Personal Certificates
- How to Grant Users Access to an Encrypted File
- Symbolic Links
- How to Create Symbolic Links
- How to Create Relative or Absolute Symbolic Links
- How to Create Symbolic Links to Shared Folders
- How to Use Hard Links
- Disk Quotas
- How to Configure Disk Quotas on a Single Computer
- How to Configure Disk Quotas from a Command Prompt
- How to Configure Disk Quotas by Using Group Policy Settings
- Disk Tools
- MoveFile and PendMoves