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")
$VHDChild
$VHDChild.Parent

image

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

image

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

Advertisements

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

  1. While I was ultimately able to make this work in my case, I did have to modify the process slightly. In my case the old location of the parent disk was on a local drive and that location had an updated version of the parent drive. This resulted in several errors. The fix was to rename the “new” parent, then apply your script. Once I was done, then rename things back. All in all, a very worth while script, thanks for posting it. Do you mind if I add this to my blog (with proper credit, of course)?

  2. Cat says:

    There is a easy way to change parent VHD disc path via VBS script: http://gallery.technet.microsoft.com/ScriptCenter/0b59c408-7d06-4453-89b3-eae5b766c8d9/

  3. haha! thanks for posting!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: