How to copy physical drive to VHD file

 | April 8, 2009 3:35 pm

I am going to describe two possible methods to copy an entire physical disk drive to a Microsoft Virtual Hard Drive VHD file using Symantec Ghost. The method to choose depends whether you may remove source physical drive and plug it in another computer for the purpose of copying, or not.

To make an accurate snapshot copy of a source physical hard drive, the drive must be offline. That’s why you can’t just run GHOST32 and copy a running Windows disk drive to the VHD.

You’ll need:

  • The VHDMount utility, which is distributed as a part of Microsoft Virtual Server but can be installed seperately.
  • The GHOST32 utility, which is a part of Symantec Ghost installation.

Any method you choose, do it at your own risk.

1. Unplug the physical drive and plug it in another computer

This method is simpler, but implies twiddling with your hardware. You’ll need a source hard drive and a destination computer where you perform the copy.

If the source hard drive was used in a computer using LBA and the destination computer uses Bit-shift sector translation (or vice versa) this method won’t work. GHOST32 on the destination computer won’t recognize the partitions on source drive if the sector translation algorithms in BIOS differ.

Plug in source drive

Plug in the source drive in the destination computer, but make sure it’s used as a secondary drive so you don’t accidentally boot from it.

Turn on the destination computer and bo0t its Windows. Not Windows on the source disk!

Prepare empty VHD file

Use Microsoft Virtual PC or Microsoft Virtual Server to create a new VHD file of desired size and form (fixed size or dynamically expanding). To get you started, I’ve prepared a 130GB dynamically expanding new VHD file, you can download here.

I wrote another post about handling the VHD files, you can read here.

Make sure you put the VHD file on a partition that is not part of the source drive you wish to copy.

Install VHDMount utility

Download Microsoft Virtual Server 2005 R2 SP1 or newer and run the setup. You can select to install the VHDMount utility only. I suggest a restart after the install.

Mount empty VHD file as local drive

Using VHDMount utility you can mount the VHD file as a local hard drive. Execute:

vhdmount /p /f image.vhd

You should receive a “The Virtual Hard Disk is successfully plugged in as a virtual disk device.” response, followed by a series of “New hardware found” messages.

Copy source drive to VHD file

Run GHOST32 utility, which can be found in the directory where you’ve installed Symantec Ghost. Using GHOST32 utility, you can copy any localy attached disk drive to any localy attached disk drive (Local DiskTo Disk). Thus, you can copy the source drive to the mounted VHD file. Make sure you choose the destination disk drive that represents the mounted VHD file, as you can easily overwrite any other local disk drive. Use GDISK32 utility to determine first which one is the source drive and which one the “MS Virtual Server” drive if uncertain.

Once transfer is complete you can safely choose not to restart the computer and just exit GHOST32. Unmouting the VHD file is sufficient.

Unmount the VHD file

Use VHDMount utility once again to unmount the VHD file. Execute:

vhdmount /u image.vhd

2. Copy over network

This method requires a bit more work, but you don’t need you to open any computer at all. I’ll assume you have a network and a DHCP server installed correctly, and two computers connected to the network. The source computer is the one with the drive to copy and the destination computer is the one to hold the VHD file.

Prepare boot media for source computer

Using Symantec Ghost Boot Wizard create a boot media with networking support for the source computer. Make sure you install the correct driver for the network adapter the source computer is using to access your network.

Boot source computer from boot media

Insert the boot media into the source computer and use it to boot the computer. The Symantec Ghost programme should start. Make sure, the Peer to peer option is not greyed out, as you’ll need it later. If it is greyed out, it means, the network drivers you installed on your boot media, are not working. Try another.

Prepare empty VHD file

Use Microsoft Virtual PC or Microsoft Virtual Server to create a new VHD file of desired size and form (fixed size or dynamically expanding). To get you started, I’ve prepared 130GB dynamically expanding new VHD file, you can download here.

I wrote another post about handling the VHD files, you can read here.

The VHD file should reside on the destination computer, if that wasn’t obvious by now.

Install VHDMount utility

Download Microsoft Virtual Server 2005 R2 SP1 or newer and run the setup on the destination computer. You can select to install the VHDMount utility only. I suggest a restart after the install.

Mount empty VHD file as local drive

Using VHDMount utility you can mount VHD file as a local hard drive on the destination computer. Execute:

vhdmount /p /f image.vhd

You should receive a “The Virtual Hard Disk is successfully plugged in as a virtual disk device.” response, followed by a series of “New hardware found” messages.

Run GHOST32 on destination computer

On the destination computer run the GHOST32 utility, which can be found in the directory where you’ve installed Symantec Ghost, and configure it as a network slave mode (Peer to peerTCP/IPSlave). Remember the IP displayed.

Copy source drive to VHD file

Go back to the source computer, where the Symantec Ghost programme is already running. Configure it as a network master (Peer to peerTCP/IPMaster). Enter the IP of the slave/destination computer. Using the Symantec Ghost programme, you can copy any localy attached disk drive on the source computer to any localy attached disk drive on the destination computer. Make sure you choose the destination disk drive that represents the mounted VHD file on the destination computer, as you can easily overwrite any other disk drive on the destination computer. Use GDISK32 utility on the destination computer to determine first which one is the “MS Virtual Server” drive if uncertain.

Once transfer is complete you can safely choose not to restart the destination computer and just exit GHOST32. Unmouting the VHD file is sufficient.

Unmount the VHD file

Use VHDMount utility on destination computer once again to unmount the VHD file. Execute:

vhdmount /u image.vhd

7 Responses to “How to copy physical drive to VHD file”

[…] More here: Simon Rozman » How to copy physical drive to VHD file […]

Alex wrote a comment on July 22, 2009

Can you do local partition from image instead of disk to disk ?

Simon Rozman wrote a comment on July 25, 2009

Yes, of course. You can choose to copy between any local partitions. Once you have your VHD file mounted, using vhdmount utility, it behaves just like any other locally attached physical volume, providing all of its partitions to the system.

There is only one limitation. The VHD file must not reside on the same partition you are trying to copy to or from the VHD file. In theory, this is impossible; in practice, it would create an unpredictable result.

Simplifier wrote a comment on February 2, 2010

You can use the free tool from Mark Russinovitch (the MS Guru)

http://technet.microsoft.com/en-us/sysinternals/ee656415.aspx

It allows you to dump a running machines drive directly to VHD format.

Read more above, or here: http://rdpfiles.com/2009/11/22/p2vhd-the-easy-way/

Which includes a workaround for a common boot-drive issue.

Luka wrote a comment on June 3, 2011

You can also mount the vhd directly in the disk management console on windows 7 and windows 2008.Vhdmount is not needed in this case.

fkjdwahfkj wrote a comment on March 14, 2012

Damn that is a long way to do this simple task on xp. As Luka wrote use disk managment in vista and win7 has option to make vhd.

Does vista or win7 support making them for removable usb drives ? If so then I doubt no small utility will be made for any win os because of this. Shame since many still won’t get vista or win7 etc because they are rubbish, unstable and no supported by many manufacture sites for drivers. Since they don’t support cannot expect many to switch to it. Did read can emaulte xp but that would be emulate and not full blown xp that xp drivers would need. Besides having to buy a new pc upgrade ram and new graphics cards etc etc

For xp there is disk2vhd but is rubbish as doesn’t see removable drives usb so on. Doubt will be updated as microsft own sysinternals now that previously made the tool.

Care to comment?