Share via


Frequently Asked Questions: Virtual Hard Disks in Windows 7 and Windows Server 2008 R2

Applies To: Windows 7, Windows Server 2008 R2

This article provides answers to common questions about virtual hard disks (VHDs) in Windows 7 and Windows Server 2008 R2.

  • What is a native VHD boot?

  • What are the different VHD file types?

  • Why are fixed VHDs recommended for production?

  • When is it appropriate to use dynamically expanding VHDs?

  • What does it mean to create, attach, and detach VHDs?

  • Are there any restrictions that I should be aware of when attaching VHDs?

  • What are the recommendations for using VHDs for native boot?

  • What is not supported for native boot when using VHDs?

What is a native VHD boot?

In Windows 7 and Windows Server 2008 R2 you can configure a VHD for native boot. This means that a VHD can be used as the running operating system on designated hardware without a parent operating system, virtual machine, or hypervisor. Furthermore, if you use native boot, you have full access to all devices and file system volumes on the physical computer, including the volumes inside the VHD. In contrast, when Windows runs in a virtual machine, only one file system volume in the virtual disk (volume C:) is available to guest machines (unless you share another volume to the virtual machine).

Note the following functionality with native boot:

  • Native boot from a VHD is available in Windows 7 Enterprise, Windows 7 Ultimate, and all versions of Windows Server 2008 R2.

  • When you perform a native boot, file system partitions that are contained in the VHD are automatically attached and the virtual volumes are visible.

  • Native boot supports all three VHD file types: fixed, dynamically expanding, and differencing. When you native boot from a dynamically expanding VHD file, the VHD is automatically expanded to the maximum size. If the physical host volume of the VHD file does not have enough free disk space for the maximum size of the dynamically expanding VHD, the boot process will fail.

  • Native boot is supported on computers that have either BIOS-based or UEFI-based firmware.

For instructions about how to configure a computer for native boot from a VHD, see the following resources: .

What are the different VHD file types?

There are three types of VHDs: fixed, dynamically expanding, and differencing. You can create these files by using the Hyper-V™ Manager or the Windows disk-management tools. For instructions about how to create and configure VHDs, see Creating Virtual Hard Disks.

Type Explanation

Fixed

A fixed VHD has an allocated size that does not change. For example, if you create a fixed VHD that is 24 gigabytes (GB), the file will be approximately 24 GB (with some space used for the internal VHD structure) regardless of the data that is written to it.

Dynamically expanding

The size of a dynamically expanding VHD is as large as the data that is written to it. As more data is written to a dynamically expanding VHD, the file increases to a maximum size. For example, a 24 GB dynamically expanding VHD is initially around 80 megabytes (MB) on the host file system. As data is written to the VHD, the file grows, but it has a maximum size of 24 GB.

Differencing

A differencing VHD is similar to a dynamically expanding VHD, but it contains only the modified disk blocks of the associated parent VHD. The parent VHD is read-only, so you must modify the differencing VHD. A differencing VHD is sometimes referred to as a “child” VHD. The parent VHD can be any of the three VHD file types, including another differencing VHD. Multiple differencing VHDs create a differencing chain. Note the following requirements for differencing VHDs:

  • You should not modify the parent of a differencing VHD. If the parent VHD is changed or replaced by a different VHD (even if it has the same file name), the block structure between the parent and differencing VHD will no longer match and the differencing VHD will be corrupted.

  • You must keep both files (the parent VHD and the differencing VHD) in the same directory on a local volume for native-boot scenarios. For native-boot VHDs, the parent VHD and the differencing disk cannot reside on different volumes, even if they reside on the same local disk. However, when you attach a differencing VHD that is not used for native boot (for example, if you plan to use it for image management), the parent VHD can be in different directories, and on a different volume or even on a remote share.

Fixed VHDs are recommended for production instead of dynamically expanding or differencing VHDs for the following reasons:

  • The I/O performance is highest for fixed VHDs because the file is not dynamically expanded.

  • When a dynamically expanding disk is expanded, the host volume could run out of space and cause the write operations to fail. Using fixed VHDs ensures this does not happen.

  • The file data will not become inconsistent due to lack of storage space or power loss. Dynamically expanding and differencing VHDs depend on multiple write operations to expand the file. The internal block allocation information can become inconsistent if all I/O operations to the VHD file and the host volume are not complete and persisted on the physical disk. This can happen if the computer suddenly loses power.

When is it appropriate to use dynamically expanding VHDs?

Dynamically expanding VHDs are useful in nonproduction environments where flexible storage requirements and frequently changing the VHD image is more of an advantage than the reliability of the data within the VHD. In addition, dynamically expanding VHDs are best for testing environments because there is less impact if you have to rebuild the VHD. For example, a test environment can use multiple dynamically expanding VHDs, each with a different Windows image and set of applications to test. If the VHD files are modified during testing or accidentally become corrupt, you can replace the VHDs from a safe copy and restart testing.

Using dynamically expanding VHDs in a test environment provides the following benefits:

  • Flexible use of disk space. You can use free space for the VHD to expand during native VHD boot. This space would have been unavailable if the volume hosted multiple VHDs in a fixed format.

  • Faster transfer time when copying VHDs between locations. The file size for a dynamically expanding VHD that is not using its maximum capacity, will transfer in less time between a network share and a local disk than a fixed VHD of equivalent maximum size.

Although rare, you may consider using dynamically expanding VHDs in production environments if 1) all of the content of the dynamically expanding VHD can be regenerated from other sources and 2) critical data is stored on volumes outside the dynamically expanding VHD.

What does it mean to create, attach, and detach VHDs?

The disk management tools (the DiskPart command-line tool and the Disk Management console) allow you to create, attach, and detach VHDs.

  • Create. You can create a new VHD with a type and size that you specify. 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(s) by using FAT, ExFAT, or NTFS.

  • Attach. Attaching a VHD activates the VHD so that it appears on the host computer as a local hard disk drive. This is sometimes called “surfacing a VHD” because the VHD is now visible to users. 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, similar to when you insert a USB flash drive into a USB connector. All users (not just the current user) can use the attached VHD in the same way they use other volumes on local physical hard disk drives (depending on security permissions). Furthermore, because you can attach a VHD that is located on a remote server message block (SMB), you can manage your images remotely.

  • Detach. Detaching a VHD stops the VHD from appearing on the host computer. When a VHD is detached, you can copy it to other locations.

Are there any restrictions that I should be aware of when attaching VHDs?

Note the following restrictions for attaching VHDs:

  • You must have volume management privileges (which is granted by default only to administrators) to attach a VHD because attaching a VHD is equivalent to bringing a hard disk drive or volume online.

  • You can only attach a VHD that is located on an NTFS volume. However, if you already have a VHD file, you can place the file on any FAT, ExFAT, NTFS, or UDFS volume for storage or transfer.

  • You cannot attach a VHD that has been compressed by NTFS or encrypted using Encrypting File System on the host volume. However, you can compress or encrypt the volumes inside the VHD if compression and encryption are otherwise supported.

  • You cannot configure two attached VHDs to be a dynamically expanding VHD. A dynamically expanding VHD is a physical disk that you have initialized for dynamic storage. It contains dynamic volumes such as simple, spanned, striped, or mirrored volumes or RAID-5 volumes.

  • You cannot attach a VHD located on a network file system (NFS) or File Transfer Protocol (FTP) server. However, as mentioned previously, you can attach a VHD that is located on a Server Message Block (SMB) share.

  • You cannot use client-side caching on the remote SMB share to attach a VHD. If you use a network file share to store VHD files that you want to attach remotely, change the caching properties of the share to disable automatic caching.

  • You can only attach two nested VHDs. When you create a VHD within another VHD, it is referred to as a nested VHD. The limit for nested VHDs is two. That is, you can attach a VHD within another attached VHD, but you cannot attach a third.

    For example, you have a fixed VHD on a computer at C:\vhd\ExampleFixed.vhd. Inside the ExampleFixed.vhd, you create a partition, initialize an NTFS file system volume, and assign the drive letter M to the volume. You then create another VHD at M:\vhd\NestedFixed.vhd. The NestedFixed.vhd file is called a nested VHD because it is created on the file system volume inside the first VHD. If you attach both VHDs (C:\vhd\ExampleFixed.vhd and M:\vhd\NestedFixed.vhd), then both N: and M: drives would be available on the computer for users to use.

  • When an operating system restarts, VHDs that were attached before reboot are not automatically attached. If you native boot to a VHD, only the file system partitions contained in the VHD are automatically attached. If there are other VHDs on the physical volume that were attached during a previous boot, they are not automatically attached.

What are the recommendations for using VHDs for native boot?

You should use the following best practice when using VHDs for native boot.

  • Store all critical data outside the native-boot VHDs. When you store critical data outside the VHD that contains the Windows boot image, it is easier to recover the data if the VHD becomes unusable.

  • Use fixed VHDs for production environments. You can use all three VHD file types (fixed, dynamically expanding, and differencing) to native boot, but we recommend using fixed VHDs for production and using dynamically expanding or differencing VHDs for development and test environments.

  • Create VHD files with a maximum size that is larger than the minimum disk requirements for the operating system. When you create a VHD that is used for native boot, the maximum size of the VHD must be larger than the minimum disk space requirements for the operating system that you intend to deploy. The minimum disk space requirements are 16 GB for Windows 7 and 10 GB (but 40 GB is recommended) for Windows Server 2008 R2. The VHD contains additional information about the virtual disk, so you need to add approximately 100 MB when determining the maximum size of the VHD.

  • Ensure that there is sufficient space on the host volume for paging files (Pagefile.sys). During native boot, a dynamically expanding VHD is automatically expanded to the maximum size on the host volume, and the paging file is created on the host volume outside the virtual volume. The paging files must be located on a physical volume outside the VHD for system performance. If the host volume does not have enough free space for a paging file, Windows attempts to find free space on another volume. The paging file size depends on how much physical RAM is available on the system (you should estimate approximately 5 GB of available space in addition to the maximum size of the VHD file).

Note

When Windows is running on a virtual machine, a paging file is created inside the VHD because the system volume in the virtual disk can be used for paging.

  • Run Sysprep to generalize the image before using a VHD for native boot on a different computer. Sysprep generalize prepares a Windows image that is installed on a physical partition or on a native boot VHD that is to be used on another computer. After you run Sysprep, you can copy the VHD to multiple physical computers or virtual machines for native boot. During the first boot from the VHD, Windows completes the specialize configuration pass to detect the hardware devices and initializes Windows to run on the new computer.

What is not supported for native boot when using VHDs?

Native boot VHDs do not support all of the features that are available when Windows is installed or deployed to a physical disk. You may need to consider the limitations of booting Windows from a VHD when you are planning how to deploy Windows for your environment. The following scenarios are not supported for native boot using VHDs:

  • Using VHDs to native boot with previous versions of Windows. Windows Vista® and Windows Server 2008 (and previous versions of Windows) do not support native boot. Native boot VHD requires significant changes to the operating system and these changes are new in Windows 7.

  • Hibernating to conserve power. An operating system that is booted from a VHD image does not support hibernation. Native boot is primarily targeted to Windows Server or managed desktops, and development and test computers where hibernation is not a critical feature.

  • Using compressed or encrypted VHDs for native boot. VHDs that have been compressed by NTFS or encrypted using Encrypting File System on the host volume are not supported for native boot.

  • Configuring native VHD boot if the host volume is protected by BitLocker. You can save a VHD file on a file system that is protected by BitLocker™, but you cannot use the VHD for native boot or enable Bitlocker on the volume(s) that are contained inside a VHD.

  • Booting to a VHD that is located on a remote share or a USB flash drive. Windows does not support booting to a remote share or a USB flash drive, whether installed on a physical volume or from a VHD. You can boot the Windows Preinstallation Environment (Windows PE) from a USB flash drive, which is supported for Windows deployment. Windows PE typically boots from either a Boot.wim or an installed image, but booting Windows PE from a VHD is not supported.

  • Upgrading the operating system booted from a VHD. If you boot from a VHD, you cannot upgrade the Windows version in the VHD to a newer version.