A Virtual Hard Disk (VHD) is a single file that is structured to represent a standard hard disk drive (HDD), and which may include an operating system and/or data. You can perform the following general actions with a VHD file:
|Create||Create a new VHD by using the available disk space on the computer, and then saving it to the location on the disk space.
When you create a virtual disk, you can use the following disk types:
|Attach||Attach (mount) the VHD so that it displays as a disk and can have a drive letter assignment.
|Detach||Detach (dismount) the VHD to remove the VHD file and drive letter assignment.
|Compact||Compact (reduce) the size of a VHD if you need to reduce the size of a dynamically expanding VHD. Dynamically expanding VHD files:
|Expand||Expand (increase) the maximum size available in a VHD.|
Use the following tools to create and manage VHD files:
|Disk Management||The Disk Management MMC snap-in performs disk-related tasks such as creating and formatting partitions and volumes, assigning drive letters, and shrinking and resizing volumes. Disk Management supports the following VHD operations:
|DiskPart||DiskPart is a text-mode command prompt tool used to manage disks, partitions, or volumes (known as objects).
DiskPart supports the following commands for VHD files:
|WIM2VHD||WIM2VHD creates VHD images from any Windows 7 installation source. WIM2VHD requires the Windows AIK, and can be used to perform the following:
|BCDEdit||BCDEdit is a command-line tool used to manage BCD stores, including:
When you are configuring a computer to boot from a new VHD, you use BCDEdit to create a new BCD boot entry.
Be aware of the following VHD details:
- A native-boot VHD is when the VHD holds an operating system and can boot to that operating system. This is also known as boot to VHD.
- Only Windows 7 Enterprise and Ultimate editions allow a native-boot VHD. (All Windows 7 versions allow you to create and attach virtual disks, but only these editions support boot to VHD.)
- File system partitions contained in the native boot VHD are automatically available and visible.
- A native-boot VHD will not degrade or reduce the performance of the computer.
- VHD multi-boot configuration allows multiple operating systems on the same volume.
- To apply a WIM file to a VHD, use the following general steps:
- Create and attach a VHD file using DiskPart.
- Locate the install.wim image to apply to the VHD.
- Apply a .wim image to a partition in the VHD. You can use the following tools to apply the image to the VHD:
- ImageX (requires the Windows AIK)
- The Install-WindowsImage.ps1 PowerShell script (does not require the Windows AIK)
- Update the Boot Configuration Data (BCD) stores on the parent operating system to boot from the VHD.
- Boot from the VHD and complete the Windows setup process.
- To install Windows 7 to a VHD, use the following general steps:
- Insert the installation media, and select the Repair your computer option.
- Open the command prompt.
- If the hard disk has not yet been used, run DiskPart to partition the drive, assign a drive letter, and format the partition.
- Run DiskPart to create and attach a VHD file inside the partition.
- Install Windows 7 to the drive that is the VHD file.
- Offline servicing lets you make changes to a Windows image without the operating system running. To update an offline image of Windows that is included in a VHD file:
- Attach the VHD file using Diskpart or Disk Management.
- Use Dism.exe to modify the image. You can:
- Add and remove drivers
- Add and remove a package or language pack
- Add and remove a local pack
- Enable or disable a Windows feature
- Change the Windows image to a higher edition
- When you are finished making the changes, detach the VHD file.
Note: You do not mount or unmount the VHD file using Dism. In addition, changes you make to the VHD file are saved immediately and cannot be undone using the /unmount-wim option with Dism. To undo changes, you will need to use Dism to remove the changes, or restore the .vhd file from a backup.