Tuesday, February 9, 2010

VM not showing up in Hyper V

Sorry for the cramped formatting on the directory views.
You can copy and paste the blockquoted sections and paste
them in Notepad and they spreadout just fine.


Ok, so during the holidays I decided to whip up a SharePoint 2010 beta VM to have a look around and see what's new and start getting a feel for the new and improved SharePoint. So I crank out a Hyper V of SP2010beta and play around a bit. The last thing I do is shut down the virtual server not save it. Then a month or so goes by while I get my SQL 2008 Developer study on and one evening (this evening) I decide to take a break from studying and go play with the SP2010beta VM again. Well, low and behold, I crank up Hyper V Manager and BAM! My VM is not showing up. Ok, no worries, I go dig around the net and find John Savill's post on just what I'm seeing(citation below) so I follow his suggested steps and get my little virtual playground back up and running.

So here is my question, what caused the corrupted XML link? Was it because I shut the virtual server down rather than saving it? Is there a "time to live" default setting for VM's that are shut down rather than saved? How can I prevent this?

At any rate, once again as a big believer in redundancy, here are the steps needed to restore a VM in HyperV Manager if it goes missing.


1. Open a command prompt as adminstrator
2. Navigate to the Hyper V default folder on your local machine.
C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines
3. From that directory you will see a symlink(hidden) to the missing VM's XML configuration file. It will look something like this;
Directory of c:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines

02/09/2010 04:42 AM .
02/09/2010 04:42 AM ..
10/05/2009 11:19 AM 77A90856-CC14-4061-83A3-10919895F84D.xml
[G:\Virtual Machines\MCTS_Configuration_Server\MCTS\Virtual Machines\77A90856-CC
14-4061-83A3-10919895F84D.xml]
09/25/2009 01:35 PM 9AEFB72A-7525-4281-BA02-B84C7C753912
09/25/2009 01:56 PM 15,626 9AEFB72A-7525-4281-BA02-B84C7C753912.xml
02/09/2010 04:42 AM BDA15939-83E1-4C5D-A560-2F8F5D0D1E93.xml
12/28/2009 04:28 PM BDA15939-83E1-4C5D-A560-2F8F5D0D1E93.
xml [G:\Virtual Machines\SP2010\SP2010beta\Virtual Machines\BDA15939-83E1-4C5D-A
560-2F8F5D0D1E93.xml]

4 File(s) 15,626 bytes
3 Dir(s) 324,143,992,832 bytes free

c:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines>

4. Run Mklink to re-establish the link to your XML configuration file
Mklink BDA15939-83E1-4C5D-A560-2F8F5D0D1E93.xml "E:\Virtual Machines\SP2010\SP2010beta\Virtual Machines\BDA15939-83E1-4C5D-A560-
2F8F5D0D1E93.xml"
5. If necessary, you may need to set the VM service account perms again.
icacls BDA15939-83E1-4C5D-A560-2F8F5D0D1E93.xml /grant "NT VIRTUAL MACHINE\BDA15939-83E1-4C5D-A560-2F8F5D0D1E93":(F) /L

Now for my particular instance I also noticed that my original drive path had changed somehow. I had the VM on my E: drive and the new bogus reference was to the G: drive. So I had to open up the XML file on my VM directory, in this case on my external drive and change the drive letter to get the VM to finally open.

So once I was finished my c:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines directory looked like this;


Directory of c:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines

02/09/2010 04:42 AM .
02/09/2010 04:42 AM ..
10/05/2009 11:19 AM 77A90856-CC14-4061-83A3-10919895F84D.xml
[G:\Virtual Machines\MCTS_Configuration_Server\MCTS\Virtual Machines\77A90856-CC
14-4061-83A3-10919895F84D.xml]
09/25/2009 01:35 PM 9AEFB72A-7525-4281-BA02-B84C7C753912
09/25/2009 01:56 PM 15,626 9AEFB72A-7525-4281-BA02-B84C7C753912.xml
02/09/2010 04:42 AM BDA15939-83E1-4C5D-A560-2F8F5D0D1E93.xml
[E:\Virtual Machines\SP2010\SP2010beta\Virtual Machines\BDA15939-83E1-4C5D-A560-
2F8F5D0D1E93.xml]
12/28/2009 04:28 PM BDA15939-83E1-4C5D-A560-2F8F5D0D1E93_bad.
xml [G:\Virtual Machines\SP2010\SP2010beta\Virtual Machines\BDA15939-83E1-4C5D-A
560-2F8F5D0D1E93.xml]
4 File(s) 15,626 bytes
3 Dir(s) 324,143,992,832 bytes free

c:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines>


Notice the bogus G: SYMLINK as opposed to the now corrected E: SYMLINK.

Thanks to John Savill
http://windowsitpro.com/article/articleid/101212/q-how-can-i-add-virtual-machines-vms-to-the-hyper-v-console.html for this solution.