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:
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") $VHDChild $VHDChild.Parent
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 $VHDChild.Parent
Now we can attach our differencing VHD without error and get back to work =).