Disk2VHD Tool - Using Command-Line Mode Page 2
Prev Page: Convert a Physical Computer to a VM
Disk2VHD Tool - Using Command-Line Mode
Disk2VHD.exe <Source Drive Letter> <VHD file name with path>
So to convert your C: drive to a VHD file, use the following command:
Disk2VHD.exe C: C:\MyVHDs\VM1.VHD
Tip: You can specify "*" in place of C: in the above command so that the Disk2VHD tool captures all the drives for conversion.
Tip: By default, when you run the Disk2VHD.exe tool for the first time on a physical computer, you will be prompted to accept the EULA. You can use the "-accepteula" switch to avoid the default behavior as shown in the below command:
Disk2VHD.exe C: C:\MyVHDs\VM1.VHD -accepteula
Note: All volumes you select will be packed into one VHD file unless you are using the command-line option to specify the VHD file name for each drive letter.
What Data Is Copied?
The conversion process copies all data from the logical volumes to VHD files. The Disk2VHD tool also copies the system-specific data such as the computer name, IP Address, MAC Address, Security Identifiers (SIDs), disk signature, etc. Pay attention when using a converted VHD on a network (especially the operating system VHD file). You might see name conflict error messages if the physical computer is still connected to the network and you are using VHD in one of the virtual machines on Hyper-V.
Where Should We Use Converted VHDs Files?
You can attach or use VHD files via one of the following:
- You can create a new virtual machine by selecting a converted VHD file as the virtual disk for the new virtual machine.
- You can attach a converted VHD on the 2nd IDE controller to one of the existing virtual machines.
- You can also browse the contents of a VHD file on the physical computer by attaching/mounting the VHD file using a computer management snap-in or the DiskPart.exe utility.
Disk2VHD Facts / Summary
- Disk2VHD.exe uses Volume Shadow Copy Service (VSS) to perform the conversion. This is achievable only if the VSS service on the physical operating system is running.
- There is no downtime while the conversion is in progress.
- Only physical drives attached to the computer are considered for the conversion. Network drives are ignored.
- Disk2VHD.exe can be used to make a VHD bootable if you have selected the "System Reserved (unlettered volume)" partition before starting the conversion.
- VHD files generated from the Disk2VHD.exe can be used with Hyper-V to create a new virtual machine or the VHD can be attached to an existing virtual machine.
- Since the Disk2VHD tool uses Volume Shadow Copy Service (VSS) for the conversion process, you can specify the local path as the VHD file destination.
- Disk2VHD takes the VSS snapshot of the drives you have selected and then begins the conversion process. This means any new data you save while the conversion is in progress will not be included in the VHD file.
- The tool can be used for simple conversions and is not designed to be a full replacement for SCVMM as discussed above.
- The conversion process may take considerably longer based on two factors:
- The size of the physical disks / partitions you have selected
- The destination location for storing the converted VHD file is the same as the source. Since Disk2VHD.exe performs I/O operations ("Read" I/O for reading data on the logical / source volume and "Write" I/O for writing to the VHD file on the same drive), it will be much slower. It is recommended to specify the VHD file path to a location other than the volumes you have selected.
- Since Windows' "Operating System boot loader" (WinLoad.exe) identifies attached disks by something called a "disk signature," never ever attach the VHD to the same computer, as the generated VHD will also have the same disk signature. This will cause the boot process to hang, or in some cases WinLoad.exe might change the boot order.
- Disk2VHD.exe might not finish the conversion process if any of the applications running on the physical computer put a lock on the disks or files. Backup applications always do this, so it is highly recommended to shut down any backup applications for smooth conversion.
In this article, we discussed the two options available from Microsoft for converting from a physical PC to a virtual machine. We learned how to use the Disk2VHD tool to convert a physical computer to a virtual machine.
We also covered how the Disk2VHD tool can be operated in a GUI mode as well as a command-line mode that can eliminate the need for interventions from the system administrators. The article also explained how the Disk2VHD tool copies system-specific data, including the computer name and other identifiers, as part of the VHD file.
Nirmal Sharma is a MCSEx3, MCITP and Microsoft MVP in Directory Services. He has specialized in Microsoft Technologies since 1994 and has followed the progression of Microsoft Operating System and software. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles on various sites and contributing to Solution IDs for www.Dynamic-SpotAction.com. Nirmal can be reached at firstname.lastname@example.org.
Prev Page: Convert a Physical Computer to a VM
Read more on "Server Virtualization Spotlight" »