Share via


Hyper-V info stored on Drive C?

Question

Friday, December 26, 2008 6:17 PM

I use Hyper-V RTM. I had created five Guests on partition D of my computer. When I created the Guests I pointed evey option  (that I knew of) to drive D. Not drive C. The vhd, snapshot directories etc are on drive D.  When I stamped a new (GHOST) image back to drive C (the image contains the Hyper-V install) I expected the Guests to show up in the Hyper-V Manager tool (as they were there before I stamped down the new image).

  1. Surprise. After imaging he Hyper-V Manager was empty and I had to add all the Guest manually. Hyper-V must store some config info on drive C that was wiped out by the new image. Anyone know where it's hiding and how to use it?

  2. One of my Guests had a snapshot. While I could locate the original (before snasphot) vhd and restore it I have not been able to find the proper vhd\ahd corresponding to the Snapshot. (So effectively I lost access ot the snapshot). How can I restore a VM with a snapshot?

TIA,

Barkingdog

All replies (5)

Monday, December 29, 2008 8:17 AM ✅Answered | 2 votes

Hi,

The following path was used by Hyper-V to store summary information of all VMs.

C:\ProgramData\Microsoft\Windows\Hyper-V

The subfolder "Virtual Machines" contains Symbolic links that point to VMs. "Snapshots" contains Symbolic links that point to Snapshots files. Hyper-V use those Symbolic links to find all VMs and snapshots.

You can re-import the original configuration files by creating symbolic links in the correct sub-directories: Virtual Machines for virtual machine configurations and Snapshots for snapshot configurations. Since Hyper-V creates unique security identity for its VMs, you’ll also need to set the DACL on the symbolic link to allow Full access by the unique VM security identity. Restoring the virtual machine configurations is fairly straightforward, but restoring the snapshot configurations is more problematic as the snapshot needs to be ACL’ed for the virtual machine that owns it.

For example, you register the virtual machine configuration stored at

E:\Vms\MyVm\Virtual Machines\befde5dd-dc82-4575-9ca7-57625301ccb9.xml using the following steps:

While the VMMS is running and from an elevated command prompt (you must be an Admin), do the following:

  1. Create the symbolic link using the command:

mklink "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\befde5dd-dc82-4575-9ca7-57625301ccb9.xml" "E:\Vms\MyVm\Virtual Machines\befde5dd-dc82-4575-9ca7-57625301ccb9.xml"

  1. Grant full access to the virtual machine’s security identity using the command:

icacls "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\befde5dd-dc82-4575-9ca7-57625301ccb9.xml" /grant "NT VIRTUAL MACHINE\befde5dd-dc82-4575-9ca7-57625301ccb9":F /l

This should restore the virtual machine configuration. You use the same process and commands to restore the snapshots, except that the snapshot configurations are
stored in the Snapshots directory and you need to specify the owning virtual machine’s security identity in the icacls command in step 2.

Building upon our earlier example, you register the snapshot at

E:\Vms\MyVm\Snapshots\1e29c039-7385-4e4b-b726-ea6b0491f8e4.xml that belongs to VM befde5dd-dc82-4575-9ca7-57625301ccb9 using the following steps:

  1. Create the symbolic link using the command:

mklink "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Snapshots\1e29c039-7385-4e4b-b726-ea6b0491f8e4.xml" "E:\Vms\MyVm\Snapshots\1e29c039-7385-4e4b-b726-ea6b0491f8e4.xml"

  1. Grant full access to the virtual machine’s security identity using the command:

icacls "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Snapshots\1e29c039-7385-4e4b-b726-ea6b0491f8e4.xml" /grant "NT VIRTUAL MACHINE\befde5dd-dc82-4575-9ca7-57625301ccb9":F /l

This should restore the snapshot configuration. Repeat these steps for all XML files in the Snapshots directory.

Thanks.


Friday, December 26, 2008 6:34 PM

Is this one of the paths you were aware of? **C:\Users\All Users\Microsoft\Windows\Hyper-V
**


Friday, December 26, 2008 6:38 PM

No.

** 0. I just checked my Windows Server 2008 box where Hyper-V is installed. There is no such path on my box.
         The closest I have is "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Hyper-V". The only other folder under
         "Users" is "Public"

  1. What info does that path contain?

  2. So I should save the info contained in that path before stamping down the GHOST of drive C. Then overwrite the "new"
        folder with that saved one?

  3. Can I modify that path to point to drive "D" or is it hardcoded in Hyper-V?

  4. And are there any other paths (on drive C)  that I should know about?

Barkingdog


Monday, December 29, 2008 4:09 PM

Mervyn,

That's a great (but troubling) explanation.  Under VMWare the Guests seemed to be more self contained than under Hyper-V. I could simply (OS) copy a folder containing a Guest  to a new machine and the copied Guest would be up and running.   Since Hyper-V retains info on drive C, regardless of the fact that my VM are on drive D (or E), my "carefree" copying days are over! Looks like the Hyper-V Import\Export routines are the only way to go under Hyper-V.

Of course, in the future, if Microsoft would allow me to repoint C:\ProgramData\Microsoft\Windows\Hyper-V to "D:" or "E" that would help. It would also help if, for each Guest, I could point that path to the directory where the Guest resides. (That would restore my ability to OS copy VM's around like in VMware. Sneaky, ain't I?)

Thank You,

Barkingdog


Tuesday, May 5, 2009 9:35 PM

Hi Mervyn,

I see this procedure does not work consistently with R2 Beta. Is there any different procedure with R2 or could this be a beta build issue?

Thanks

Doomma