Category Archives: Hyper V

How to rebase differencing disk VHDs (or how to change the parent of a differencing VHD when the parent has moved)

I am a big fan of differencing VHDs as the provide tremendous power when working with large database but they also come with their own set of complications.

One of those complications that can arise is when due to files being moved or folder structures being reorganized the parent VHD of your differencing VHD is no longer accessible. After you try and attach your differencing VHD you may see an error message like this one:

Virtual Disk Manager The network path was not found.

We can use the following power shell from a Windows 7 PC with the latest version of Microsoft Virtual PC that comes with Windows XP Mode installed to take a look at the parent property of our differencing disk to see if something is wrong

$vpc=new-object -com VirtualPC.Application
$VHDChild = $vpc.GetHardDisk("C:\NAV2010.06.10_Diff")


In my case I recently changed the IP address of a NAS that was storing the parent VHD and assigned a DNS record to the NAS so that I wouldn’t have to keep track of it’s IP address but now the path to the parent VHD that is stored in my differencing VHD is no longer valid.

Thankfully this is fairly easy to fix. All we need to do is add the following code so that we get a new $VHDParent object using the corrected path and then assign that object to the Parent property of our differencing disk

$VHDParent = $vpc.GetHardDisk("\\devnas\Data_Backups SQLCluster1\NAV2010.06.10.vhd")
$VHDChild.Parent = $VHDParent


Now we can attach our differencing VHD without error and get back to work =).


How to create a differencing VHD that refers to a parent VHD that is on a network share from Windows 7

I love the fact that Windows 7 can attach VHD disks as if they were local hard disks. This allows me to pull off some very interesting stuff that I will blog about later but one pain point has been that through the UI with only Windows 7 I cannot create a differencing VHD from a parent VHD that is stored at a UNC path on the network.

The solution to this is to install the latest version of Microsoft Virtual PC which can be downloaded form the Windows XP Mode website. After installing this you are now able to create differencing disks based on parent VHDs that are stored on your network at a UNC path as shown below:

$vpc=new-object -com VirtualPC.Application
$vpc.CreateDifferencingVirtualHardDisk("\\devnas\Data_Backups\SQLCluster1\NAV 2010.08.20 Differencing.vhd","\\devnas\Data_Backups\SQLCluster1\NAV 2010.08.20 Full.vhd")

Note: If you still have the parent VHD attached to a machine this command will silently fail. Make sure that the parent is not being used and is not attached to any machine before running this.

In a future post I will talk about some of the use cases for this technique that make it invaluable.

Hint: Multiple 300GB+ database development from a laptop with only an 120 GB hard drive as if all DBs were local

Control Windows Virtual PC from PowerShell

I have used the command line interface (CLI) for Sun’s Virtual Box and for Hyper V but I didn’t realize that Virtual PC also can be accessed through PowerShell. This might be the key to creating network based differencing disks natively on Windows 7 which currently isn’t something that can be done in a straightforward way through the GUI and even the way that it can be done has limitations (like not being able to create a differencing disk with the parent disk on the network).

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS H:\> $vpc=new-object -com VirtualPC.Application
PS H:\> $vpc
HostInfo                    : System.__ComObject
VirtualMachines             : System.__ComObject
VirtualNetworks             : System.__ComObject
UnconnectedNetworkAdapters  : System.__ComObject
SupportDrivers              : System.__ComObject
Tasks                       : System.__ComObject
MinimumMemoryPerVM          : 4
MaximumMemoryPerVM          : 3575
SuggestedMaximumMemoryPerVM : 3217
MaximumFloppyDrivesPerVM    : 1
MaximumSerialPortsPerVM     : 2
MaximumParallelPortsPerVM   : 1
MaximumNetworkAdaptersPerVM : 4
MaximumNumberOfIDEBuses     : 2
DefaultVMConfigurationPath  : C:\Users\cmagnuson\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines\
SearchPaths                 : {}
USBDeviceCollection         : System.__ComObject
Name                        : Windows Virtual PC
Version                     : 6.1.7600.16393
UpTime                      : 6
PS H:\> $vm = $vpc.FindVirtualMachine(
PS H:\> $vm = $vpc.FindVirtualMachine("IE 6")
PS H:\> $vm
Name                  : IE 6
ConfigID              : {DB33D85B-1FAC-4A67-910A-33EE4A4F06FC}
File                  : C:\Users\cmagnuson\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines\IE 6.vmc
Accountant            : System.__ComObject
GuestOS               : System.__ComObject
Display               : System.__ComObject
Keyboard              : System.__ComObject
Mouse                 :
State                 : 2
ShutdownActionOnQuit  : 0
SavedStateFilePath    : C:\Users\cmagnuson\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines\IE 6.vsv
BIOSGUID              : {D5356F8F-4383-4B68-ACDA-03D1A06E5C46}
BIOSSerialNumber      : 8425-1374-7407-2656-1007-9980-44
BaseBoardSerialNumber : 8425-1374-7407-2656-1007-9980-44
ChassisSerialNumber   : 8425-1374-7407-2656-1007-9980-44
ChassisAssetTag       : 1746-8710-8930-6641-7796-6780-67
HardDiskConnections   : System.__ComObject
Undoable              : False
UndoAction            : 1
DVDROMDrives          : System.__ComObject
FloppyDrives          : System.__ComObject
NetworkAdapters       : System.__ComObject
SerialPorts           : System.__ComObject
ParallelPorts         : System.__ComObject
ProcessorSpeed        : 2926
HasMMX                : True
HasSSE                : True
HasSSE2               : False
Has3DNow              : False
RdpPipeName           :
Notes                 :
Memory                : 1024
AttachedDriveTypes    : {1, 0, 2, 0}
PS H:\>

Original Source: