Someday I had a VM installed on a passthrough Hard Disk Drive.
Some weekend, instead of going out, I decided I required that bloody drive to experiment “some more” (‘though, a compassionate hoarder feeling inside of me didn’t want to bork that OS).
My solution was to migrate my Virtual Machine into a VHD image (so I could finally reclaim that unused hdd space back!).
The virtualised OS was an instance of Microsoft Windows Server 2008 R2 SP1 (but your flavour may vary).
Win2k8R2SP1 was installed within a 111GB Passthrough Hard Disk Drive.
A Virtual Machine hosted within a Windows Server Standard 2008 R2 SP1 with the Hyper-V Role enabled was booting off the passthrough Hard Disk Drive.
There are 2 ways (that I know of…), to accomplish the Passthrough to VHD migration:
- With Disk2vhd from sysinternals.
- With “New Disk Wizard” from Hyper-V (no additional software required).
I found not using additional software was more convenient (but this shall not influence you decision, since I reckon it is just a matter of personal preference).
To migrate a physical Passthrough hard disk drive to a VHD image with disk2vhd, you simply:
- Assess the amount of data to be transferred (ie. From & To).
- Shutdown the VM to be migrated (make sure you Shut it Down -- ie. do not Turn it Off!).
- Open “Disk Management” (diskmgmt.msc) on your Hyper-V Host.
- Locate the Hard Disk Drive to be migrated.
- Update the disk (to be imaged) status to “online” (so the Hyper-V Host can see it).
- Win + E Then Paste: “http://live.sysinternals.com/” On your Windows Explorer Address Bar (courtesy of WebDAV!).
Disk2vhd will list all your (hdds’) partitions.
- Locate your disk’s partitions from the “Volumes to include”-list and select the partiotions by putting a checkmark on them.
- Click on the “…”-Button to Browse for the location where to save the VHD image of your passthrough hdd (make sure -- again -- there’s plenty of space!).
- Click on the “Create”-Button to generate the VHD image of your VM.
Now get some of your favourite nuts while waiting & you’re done!
Here I’ll show a step-by-step howto migrate a physical Passthrough hard disk drive to a VHD image with my favourite Hyper-V Method.
Open Hyper-V Manager & Launch the “New Hard Disk Wizard”.
Click on “New…” and Select Hard Disk (that’s right -- just as if you wanted to create a “new” Hard Disk).
The “New Virtual Hard Disk Wizard” will start.
Proceed as follows…
On disk type, Select “Dynamically Expanding” (to create a space-“optimized” image -- ie. one which takes less space).
Feel free to choose “Fixed” if you want a FULL image (because, you know, you have more than “plenty of space“).
Click Next to proceed to “Specify Name & Location”.
Specify the VHD Image Name and Location.
My VHD image has been named famx11 (same as the parent VM). What’s your naming convention? Good, stick with it!
Below is the crucial part: when you choose to create a new VHD, you are can either “Create a new blank virtual hard disk” or “Copy the contents of [a pre-existing] physical disk” (even ‘though Disk Management reports the disk as OFFLINE!).
Select your Passthrough Hard Disk Drive you wish to migrate to a VHD.
Here I selected my 111GB “PHYSICALDRIVE2”.
Click on Finish to start the Image creation process.
A new dialog window will show you another
meaningless progress bar which I suggest you don’t stare at -- just grab some chips!
Once the image creation process has finished, I strongly recommend you to test the image (ie. Before moving it to, say, your NAS).
Always trust but always verify…
To Test you VHD Image, on Hyper-V Manager.
- Open the VM Settings to which the passthrough hdd is attached to.
- Remove (but don’t delete yet), the passthrough hdd from your VM.
- Attach the VHD image (ie. replace the passthrough disk with the VHD Image).
- Start the VM and check that your VM boots as expected.
Did I already tell you that the above is incredibly easy?