Latest Blog Posts

We're members of the

We've ridden there:

Demo

Layne's certifications:

 

VHD Facts

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:

Action Description
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.
  • VHD files have a .vhd file extension.
  • When you first create a VHD, it is similar to an uninitialized hard disk drive.
  • You can create one or more partitions in the VHD and format the partition by using FAT, ExFAT, or NTFS.

When you create a virtual disk, you can use the following disk types:

  • A fixeddisk occupies a set amount of hard disk space in the management operating system. The size of the virtual hard disk file is the total storage capacity of the virtual disk.
    • This disk type takes longer to create than other disk types.
    • The entire disk size, including empty space within the virtual hard disk, is reserved on the physical disk.
    • Performance is improved because the entire virtual disk is a contiguous block.
  • A dynamically expandingdisk allocates physical disk space in the .vhd file as virtual disk storage is used by the virtual machine.
    • The size of the .vhd file grows as more disk space is used by the virtual machine.
    • This disk type makes the most efficient use of hard disk space.
    • It is possible for the physical disk to run out of space as the .vhd file size grows.
Attach Attach (mount) the VHD so that it displays as a disk and can have a drive letter assignment.
  • If the VHD already has a disk partition and file system volume when you attach it, the volume inside the VHD is assigned a drive letter. The assigned drive letter is then available for use.
  • Depending on security permissions, all users can use the attached VHD in the same way they use other volumes on local physical hard disk drives.
  • You can only attach a VHD that is located on an NTFS volume.
  • You cannot attach a VHD that has been compressed by NTFS or encrypted using Encrypting File System (EFS) on the host volume.
  • You can attach a VHD as read-only to view, but not modify, the contents.
Detach Detach (dismount) the VHD to remove the VHD file and drive letter assignment.
  • Detaching a VHD stops the VHD from appearing on the host computer.
  • You should detach the VHD before copying it to other locations.
  • You can delete a VHD file as it is detached.
Compact Compact (reduce) the size of a VHD if you need to reduce the size of a dynamically expanding VHD. Dynamically expanding VHD files:
  • Increase in size as files are added.
  • Do not automatically reduce in size when files are deleted.
Expand Expand (increase) the maximum size available in a VHD.

Use the following tools to create and manage VHD files:

Tool Description
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:
  • Create
  • Attach
  • Detach
DiskPart DiskPart is a text-mode command prompt tool used to manage disks, partitions, or volumes (known as objects).
  • Before using DiskPart commands on a disk, partition, or volume, you must first list and then select the object to give it focus.
  • When an object has focus, any DiskPart commands that you type act on that object.

DiskPart supports the following commands for VHD files:

  • create vdisk maximum creates a new VHD, with the size of the VHD file expressed in MB. The VHD file should include the .vhd extension.
  • attach vdisk attaches a VHD and assigns it a drive letter.
  • detach vdisk detaches a VHD.
  • compact vdisk compacts or reduces the size of a VHD.
  • expand vdisk expands the maximum size available in a VHD.
  • detail vdisk displays information about a VHD, including the path and file name, state, virtual size, and physical size.
WIM2VHD WIM2VHD creates VHD images from any Windows 7 installation source. WIM2VHD requires the Windows AIK, and can be used to perform the following:
  • 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.
  • Apply updates to VHDs.
BCDEdit BCDEdit is a command-line tool used to manage BCD stores, including:
  • Creating new BCD stores
  • Modifying existing BCD stores
  • Adding boot menu parameters

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:
    1. Create and attach a VHD file using DiskPart.
    2. Locate the install.wim image to apply to the VHD.
    3. 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)
    4. Update the Boot Configuration Data (BCD) stores on the parent operating system to boot from the VHD.
    5. Boot from the VHD and complete the Windows setup process.
    You can use WIM2VHD to automatically perform many of these steps.
  • To install Windows 7 to a VHD, use the following general steps:
    1. Insert the installation media, and select the Repair your computer option.
    2. Open the command prompt.
    3. If the hard disk has not yet been used, run DiskPart to partition the drive, assign a drive letter, and format the partition.
    4. Run DiskPart to create and attach a VHD file inside the partition.
    5. 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:
    1. Attach the VHD file using Diskpart or Disk Management.
    2. 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
      You can perform multiple actions by applying an Unattend file to the offline image. When using this method, insert the changes you want to apply in the offlineServicing section of the Unattend file. With the file created, use the /Apply-Unattend option to use the file to update the image.
    3. 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.