Introduction

Disk2vhd

Disk2vhd

Copyright © 2009-2013 Mark Russinovich

Sysinternals - www.sysinternals.com

 

Disk2vhd is a utility that creates VHD (Virtual Hard Disk) or VHDX (usable on Windows 8 and higher and Windows Server 2012 and higher) versions of physical disks for use in Microsoft Virtual PC or Microsoft Hyper-V virtual machines (VMs). The difference between Disk2vhd and other physical-to-virtual tools it that you can run Disk2vhd on a system that's online. Disk2vhd uses Windows' Volume Snapshot capability, introduced in Windows XP, to create consistent point-in-time snapshots of the volumes you want to include in a conversion. You can even have Disk2vhd create the VHDs on local volumes, even ones being converted (though performance is better when the VHD is on a disk different than ones being converted).

Disk2vhd runs Windows XP SP2, Windows Server 2003 SP1, and higher, including x64 systems.

Using Disk2vhd

The Disk2vhd user interface lists the volumes present on the system. It will create one VHD for each disk on which selected volumes reside. It preserves the partitioning information of the disk, but only copies the data contents for volumes on the disk that are selected. This enables you to capture just system volumes and exclude data volumes, for example.

Note: Virtual PC supports a maximum virtual disk size of 127GB. If you create a VHD from a larger disk, even if you only include data from a smaller volume, it will not be accessible from a Virtual PC VM. In addition Virtual PC doesn't support the Multiprocessor Specification, which means that it won't be able to boot VHD's from multiprocessor Windows XP and Windows Server 2003 systems.

If you create a VHD from Windows XP or Windows Server 2003 and plan on booting the VHD within Virtual PC, select the "Prepare VHD for use in Virtual PC" option, which ensures that the HAL (Windows Hardware Abstraction Layer) installed in the VHD is compatible with Virtual PC.  

To use VHDs produced by Disk2vhd, create a VM with the desired characteristics and add the VHDs to the VM's configuration as IDE disks. On first boot, a VM booting a captured copy of Windows will detect the VM's hardware and automatically install drivers, if present in the image. If the required drivers are not present, install them via the Virtual PC or Hyper-V integration components. You can also attach to VHDs using the Windows 7 or Windows Server 2008 R2 Disk Management or Diskpart utilities.

Note: Do not attach to VHDs on the same system on which you created them if you plan on booting from them. If you do so, Windows will assign the VHD a new disk signature to avoid a collision with the signature of the VHD's source disk. Windows references disks in the boot configuration database (BCD) by disk signature, so when that happens Windows booted in a VM will fail to locate the boot disk.

Command Line Usage

Disk2vhd includes command-line options that enable you to script the creation of VHDs. Specify the volumes you want included in a snapshot by drive letter (e.g. c:) or use "*" to include all volumes. To create a VHD-formatted file, specify a .vhd extension, and for a VHDX output file use a .vhdx extension.

Usage: disk2vhd [-h] <[drive: [drive:]...]|[*]> <vhdfile>

-h   Fix up the HAL in the VHD to be compatible with Virtual PC (Windows XP and Windows Server 2003 only).

Example: disk2vhd * c:\vhd\snapshot.vhdx